address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf3b41c583f4b2c728105e33b0dfe4b1fed8a27d1
// File: @openzeppelin/contracts/utils/Context.sol // 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; } } // File: @openzeppelin/contracts/introspection/IERC165.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol pragma solidity >=0.6.2 <0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // File: @openzeppelin/contracts/introspection/ERC165.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/EnumerableSet.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: @openzeppelin/contracts/utils/EnumerableMap.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; // Suffix string private _suffix = ".json"; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory base = baseURI(); string memory suffixData = suffix(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return "https://gateway.pinata.cloud/ipfs/QmZQ5jedigFoNsh8eEZ9TtAH5fyNfut8p86fCGuqVY2D1B/1.json"; } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString(), suffixData)); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } function suffix() public view virtual returns (string memory) { return _suffix; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @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; } } interface LootInterface { function ownerOf(uint256 tokenId) external view returns (address owner); } /** * @title LootPebble contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation */ contract LootPebble is ERC721, ReentrancyGuard, Ownable { using SafeMath for uint256; uint256 public publicPrice = 25000000000000000; //0.025 ETH uint256 public nextId = 1001; uint256 public freerollId = 9801; constructor() ERC721("LootPebble (for Adventurers)", "LootPebble (for Adventurers)") { } //Loot Contract address public lootAddress = 0xeC43a2546625c4C82D905503bc83e66262f0EF84; LootInterface lootContract = LootInterface(lootAddress); function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } //LootRock function mintWithRock(uint rockId) public payable nonReentrant { require(lootContract.ownerOf(rockId) == msg.sender, "Not the owner of this loot"); require(!_exists(rockId), "This token has already been minted"); for (uint i=rockId; i<1001; i+=100) { _safeMint(msg.sender, i); } } function multiMint(uint count) public payable nonReentrant { require((publicPrice * count) <= msg.value, "Ether value sent is not correct"); require(count < 21, "Only 20 NFT are allowed to be minted"); require(nextId + count < 9801, "Supply exhausted"); for (uint i=0; i<count; i++) { _safeMint(msg.sender, nextId); nextId++; } } function freeroll(address[] memory addresses) public payable nonReentrant onlyOwner { require(freerollId + addresses.length < 10001, "Supply exhausted"); for (uint i=0; i<addresses.length; i++) { _safeMint(addresses[i], freerollId); freerollId++; } } }
0x6080604052600436106101cd5760003560e01c80636da41cec116100f7578063a22cb46511610095578063c87b56dd11610064578063c87b56dd14610bd7578063e985e9c514610c8b578063f2fde38b14610d12578063f7073c3a14610d63576101cd565b8063a22cb46514610a0f578063a945bf8014610a6c578063ab00492f14610a97578063b88d4fde14610ac5576101cd565b80638da5cb5b116100d15780638da5cb5b146108e55780638e2ee3481461092657806395d89b4114610954578063a1339986146109e4576101cd565b80636da41cec146107b157806370a0823114610869578063715018a6146108ce576101cd565b80632f745c591161016f57806355f804b31161013e57806355f804b3146105c957806361b8ce8c146106915780636352211e146106bc5780636c0360eb14610721576101cd565b80632f745c59146104795780633ccfd60b146104e857806342842e0e146104ff5780634f6ccce71461057a576101cd565b8063095ea7b3116101ab578063095ea7b3146103375780630e4393261461039257806318160ddd146103d357806323b872dd146103fe576101cd565b806301ffc9a7146101d257806306fdde0314610242578063081812fc146102d2575b600080fd5b3480156101de57600080fd5b5061022a600480360360208110156101f557600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610df3565b60405180821515815260200191505060405180910390f35b34801561024e57600080fd5b50610257610e5a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561029757808201518184015260208101905061027c565b50505050905090810190601f1680156102c45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102de57600080fd5b5061030b600480360360208110156102f557600080fd5b8101908080359060200190929190505050610efc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561034357600080fd5b506103906004803603604081101561035a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f97565b005b34801561039e57600080fd5b506103a76110db565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103df57600080fd5b506103e8611101565b6040518082815260200191505060405180910390f35b34801561040a57600080fd5b506104776004803603606081101561042157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611112565b005b34801561048557600080fd5b506104d26004803603604081101561049c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611188565b6040518082815260200191505060405180910390f35b3480156104f457600080fd5b506104fd6111e3565b005b34801561050b57600080fd5b506105786004803603606081101561052257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112e1565b005b34801561058657600080fd5b506105b36004803603602081101561059d57600080fd5b8101908080359060200190929190505050611301565b6040518082815260200191505060405180910390f35b3480156105d557600080fd5b5061068f600480360360208110156105ec57600080fd5b810190808035906020019064010000000081111561060957600080fd5b82018360208201111561061b57600080fd5b8035906020019184600183028401116401000000008311171561063d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611324565b005b34801561069d57600080fd5b506106a66113df565b6040518082815260200191505060405180910390f35b3480156106c857600080fd5b506106f5600480360360208110156106df57600080fd5b81019080803590602001909291905050506113e5565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561072d57600080fd5b5061073661141c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561077657808201518184015260208101905061075b565b50505050905090810190601f1680156107a35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610867600480360360208110156107c757600080fd5b81019080803590602001906401000000008111156107e457600080fd5b8201836020820111156107f657600080fd5b8035906020019184602083028401116401000000008311171561081857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506114be565b005b34801561087557600080fd5b506108b86004803603602081101561088c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116c0565b6040518082815260200191505060405180910390f35b3480156108da57600080fd5b506108e3611795565b005b3480156108f157600080fd5b506108fa611905565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6109526004803603602081101561093c57600080fd5b810190808035906020019092919050505061192f565b005b34801561096057600080fd5b50610969611b8e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156109a957808201518184015260208101905061098e565b50505050905090810190601f1680156109d65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156109f057600080fd5b506109f9611c30565b6040518082815260200191505060405180910390f35b348015610a1b57600080fd5b50610a6a60048036036040811015610a3257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611c36565b005b348015610a7857600080fd5b50610a81611dec565b6040518082815260200191505060405180910390f35b610ac360048036036020811015610aad57600080fd5b8101908080359060200190929190505050611df2565b005b348015610ad157600080fd5b50610bd560048036036080811015610ae857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610b4f57600080fd5b820183602082011115610b6157600080fd5b80359060200191846001830284011164010000000083111715610b8357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050612003565b005b348015610be357600080fd5b50610c1060048036036020811015610bfa57600080fd5b810190808035906020019092919050505061207b565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610c50578082015181840152602081019050610c35565b50505050905090810190601f168015610c7d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610c9757600080fd5b50610cfa60048036036040811015610cae57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612242565b60405180821515815260200191505060405180910390f35b348015610d1e57600080fd5b50610d6160048036036020811015610d3557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506122d6565b005b348015610d6f57600080fd5b50610d786124cb565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610db8578082015181840152602081019050610d9d565b50505050905090810190601f168015610de55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ef25780601f10610ec757610100808354040283529160200191610ef2565b820191906000526020600020905b815481529060010190602001808311610ed557829003601f168201915b5050505050905090565b6000610f078261256d565b610f5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613ac0602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610fa2826113e5565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611029576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613b9b6021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661104861258a565b73ffffffffffffffffffffffffffffffffffffffff16148061107757506110768161107161258a565b612242565b5b6110cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180613a136038913960400191505060405180910390fd5b6110d68383612592565b505050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061110d600261264b565b905090565b61112361111d61258a565b82612660565b611178576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180613bbc6031913960400191505060405180910390fd5b611183838383612754565b505050565b60006111db82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061299790919063ffffffff16565b905092915050565b6111eb61258a565b73ffffffffffffffffffffffffffffffffffffffff16611209611905565b73ffffffffffffffffffffffffffffffffffffffff1614611292576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156112dd573d6000803e3d6000fd5b5050565b6112fc83838360405180602001604052806000815250612003565b505050565b6000806113188360026129b190919063ffffffff16565b50905080915050919050565b61132c61258a565b73ffffffffffffffffffffffffffffffffffffffff1661134a611905565b73ffffffffffffffffffffffffffffffffffffffff16146113d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6113dc816129dd565b50565b600e5481565b600061141582604051806060016040528060298152602001613a756029913960026129f79092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114b45780601f10611489576101008083540402835291602001916114b4565b820191906000526020600020905b81548152906001019060200180831161149757829003601f168201915b5050505050905090565b6002600b541415611537576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600b8190555061154761258a565b73ffffffffffffffffffffffffffffffffffffffff16611565611905565b73ffffffffffffffffffffffffffffffffffffffff16146115ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6127118151600f54011061166a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f537570706c79206578686175737465640000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156116b45761169582828151811061168557fe5b6020026020010151600f54612a16565b600f60008154809291906001019190505550808060010191505061166d565b506001600b8190555050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613a4b602a913960400191505060405180910390fd5b61178e600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612a34565b9050919050565b61179d61258a565b73ffffffffffffffffffffffffffffffffffffffff166117bb611905565b73ffffffffffffffffffffffffffffffffffffffff1614611844576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6002600b5414156119a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600b819055503373ffffffffffffffffffffffffffffffffffffffff16601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611a3a57600080fd5b505afa158015611a4e573d6000803e3d6000fd5b505050506040513d6020811015611a6457600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614611afe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f4e6f7420746865206f776e6572206f662074686973206c6f6f7400000000000081525060200191505060405180910390fd5b611b078161256d565b15611b5d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806139f16022913960400191505060405180910390fd5b60008190505b6103e9811015611b8257611b773382612a16565b606481019050611b63565b506001600b8190555050565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611c265780601f10611bfb57610100808354040283529160200191611c26565b820191906000526020600020905b815481529060010190602001808311611c0957829003601f168201915b5050505050905090565b600f5481565b611c3e61258a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cdf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060056000611cec61258a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611d9961258a565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b600d5481565b6002600b541415611e6b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b6002600b819055503481600d54021115611eed576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45746865722076616c75652073656e74206973206e6f7420636f72726563740081525060200191505060405180910390fd5b60158110611f46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180613bed6024913960400191505060405180910390fd5b61264981600e540110611fc1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f537570706c79206578686175737465640000000000000000000000000000000081525060200191505060405180910390fd5b60005b81811015611ff757611fd833600e54612a16565b600e600081548092919060010191905055508080600101915050611fc4565b506001600b8190555050565b61201461200e61258a565b83612660565b612069576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180613bbc6031913960400191505060405180910390fd5b61207584848484612a49565b50505050565b60606120868261256d565b6120db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180613b6c602f913960400191505060405180910390fd5b60006120e561141c565b905060006120f16124cb565b905060008251141561211f57604051806080016040528060578152602001613aec605791399250505061223d565b8161212985612abb565b826040516020018084805190602001908083835b60208310612160578051825260208201915060208101905060208303925061213d565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b602083106121b1578051825260208201915060208101905060208303925061218e565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b6020831061220257805182526020820191506020810190506020830392506121df565b6001836020036101000a0380198251168184511680821785525050505050509050019350505050604051602081830303815290604052925050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6122de61258a565b73ffffffffffffffffffffffffffffffffffffffff166122fc611905565b73ffffffffffffffffffffffffffffffffffffffff1614612385576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561240b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806139556026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6060600a8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156125635780601f1061253857610100808354040283529160200191612563565b820191906000526020600020905b81548152906001019060200180831161254657829003601f168201915b5050505050905090565b6000612583826002612c0290919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16612605836113e5565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061265982600001612c1c565b9050919050565b600061266b8261256d565b6126c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806139c5602c913960400191505060405180910390fd5b60006126cb836113e5565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061273a57508373ffffffffffffffffffffffffffffffffffffffff1661272284610efc565b73ffffffffffffffffffffffffffffffffffffffff16145b8061274b575061274a8185612242565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612774826113e5565b73ffffffffffffffffffffffffffffffffffffffff16146127e0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180613b436029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612866576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061397b6024913960400191505060405180910390fd5b612871838383612c2d565b61287c600082612592565b6128cd81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612c3290919063ffffffff16565b5061291f81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612c4c90919063ffffffff16565b5061293681836002612c669092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006129a68360000183612c9b565b60001c905092915050565b6000806000806129c48660000186612d1e565b915091508160001c8160001c9350935050509250929050565b80600990805190602001906129f3929190613855565b5050565b6000612a0a846000018460001b84612db7565b60001c90509392505050565b612a30828260405180602001604052806000815250612ead565b5050565b6000612a4282600001612f1e565b9050919050565b612a54848484612754565b612a6084848484612f2f565b612ab5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806139236032913960400191505060405180910390fd5b50505050565b60606000821415612b03576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612bfd565b600082905060005b60008214612b2d578080600101915050600a8281612b2557fe5b049150612b0b565b60008167ffffffffffffffff81118015612b4657600080fd5b506040519080825280601f01601f191660200182016040528015612b795781602001600182028036833780820191505090505b50905060006001830390508593505b60008414612bf557600a8481612b9a57fe5b0660300160f81b82828060019003935081518110612bb457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8481612bed57fe5b049350612b88565b819450505050505b919050565b6000612c14836000018360001b613148565b905092915050565b600081600001805490509050919050565b505050565b6000612c44836000018360001b61316b565b905092915050565b6000612c5e836000018360001b613253565b905092915050565b6000612c92846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b6132c3565b90509392505050565b600081836000018054905011612cfc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806139016022913960400191505060405180910390fd5b826000018281548110612d0b57fe5b9060005260206000200154905092915050565b60008082846000018054905011612d80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613a9e6022913960400191505060405180910390fd5b6000846000018481548110612d9157fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390612e7e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e43578082015181840152602081019050612e28565b50505050905090810190601f168015612e705780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110612e9157fe5b9060005260206000209060020201600101549150509392505050565b612eb7838361339f565b612ec46000848484612f2f565b612f19576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806139236032913960400191505060405180910390fd5b505050565b600081600001805490509050919050565b6000612f508473ffffffffffffffffffffffffffffffffffffffff16613593565b612f5d5760019050613140565b60006130c763150b7a0260e01b612f7261258a565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612ff6578082015181840152602081019050612fdb565b50505050905090810190601f1680156130235780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613923603291398773ffffffffffffffffffffffffffffffffffffffff166135a69092919063ffffffff16565b905060008180602001905160208110156130e057600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000808360010160008481526020019081526020016000205490506000811461324757600060018203905060006001866000018054905003905060008660000182815481106131b657fe5b90600052602060002001549050808760000184815481106131d357fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061320b57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061324d565b60009150505b92915050565b600061325f83836135be565b6132b85782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506132bd565b600090505b92915050565b600080846001016000858152602001908152602001600020549050600081141561336a57846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050613398565b8285600001600183038154811061337d57fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613442576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b61344b8161256d565b156134be576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b6134ca60008383612c2d565b61351b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612c4c90919063ffffffff16565b5061353281836002612c669092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b60606135b584846000856135e1565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b60608247101561363c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061399f6026913960400191505060405180910390fd5b61364585613593565b6136b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061370657805182526020820191506020810190506020830392506136e3565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613768576040519150601f19603f3d011682016040523d82523d6000602084013e61376d565b606091505b509150915061377d828286613789565b92505050949350505050565b606083156137995782905061384e565b6000835111156137ac5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156138135780820151818401526020810190506137f8565b50505050905090810190601f1680156138405780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261388b57600085556138d2565b82601f106138a457805160ff19168380011785556138d2565b828001600101855582156138d2579182015b828111156138d15782518255916020019190600101906138b6565b5b5090506138df91906138e3565b5090565b5b808211156138fc5760008160009055506001016138e4565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e5468697320746f6b656e2068617320616c7265616479206265656e206d696e7465644552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e68747470733a2f2f676174657761792e70696e6174612e636c6f75642f697066732f516d5a51356a65646967466f4e73683865455a39547441483566794e6675743870383666434775715659324431422f312e6a736f6e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665644f6e6c79203230204e46542061726520616c6c6f77656420746f206265206d696e746564a264697066735822122086a2bc016b9abb0a7c9c3e934b87e144e9102797e421b421cef459051d4933ee64736f6c63430007060033
[ 13, 5 ]
0xf3b4e66e0e7750a941e4b25026db99570310d398
/** *Submitted for verification at Etherscan.io on 2022-03-28 */ /** ░█████╗░██████╗░███████╗███╗░░░███╗███████╗ ██╔══██╗██╔══██╗██╔════╝████╗░████║██╔════╝ ███████║██████╔╝█████╗░░██╔████╔██║█████╗░░ ██╔══██║██╔═══╝░██╔══╝░░██║╚██╔╝██║██╔══╝░░ ██║░░██║██║░░░░░███████╗██║░╚═╝░██║███████╗ ╚═╝░░╚═╝╚═╝░░░░░╚══════╝╚═╝░░░░░╚═╝╚══════╝ Are you brave enough to Ape ME?? https://t.me/ApeMe_ERC20 */ // 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 ApeMe 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("Ape Me", "APEME") { 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 = 10; uint256 _buyLiquidityFee = 4; uint256 _buyBuyBackFee = 0; uint256 _buyDevFee = 1; uint256 _sellMarketingFee =10; uint256 _sellLiquidityFee = 4; uint256 _sellBuyBackFee = 0; uint256 _sellDevFee = 1; uint256 totalSupply = 1 * 1e9 * 1e18; maxTransactionAmount = totalSupply * 30 / 1000; // 0.5% maxTransactionAmountTxn maxWallet = totalSupply * 3 / 100; // 1% 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(14 <= buyTotalFees, "Must keep fees at 14% 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(14 <= sellTotalFees, "Must keep fees at 14% 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(10 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); } }
0x6080604052600436106103f35760003560e01c80637bce5a0411610208578063b62496f511610118578063e2f45605116100ab578063f2fde38b1161007a578063f2fde38b14610bcf578063f637434214610bef578063f755e17c14610c05578063f8b45b0514610c32578063fc155d1d14610c4857600080fd5b8063e2f4560514610b6e578063e7ad9fcd14610b84578063e884f26014610ba4578063f11a24d314610bb957600080fd5b8063c8c8ebe4116100e7578063c8c8ebe414610adc578063d257b34f14610af2578063d85ba06314610b12578063dd62ed3e14610b2857600080fd5b8063b62496f514610a53578063bbc0c74214610a83578063c024666814610aa2578063c876d0b914610ac257600080fd5b806395d89b411161019b578063a0d82dc51161016a578063a0d82dc5146109b0578063a457c2d7146109c6578063a9059cbb146109e6578063a9769b3b14610a06578063aacebbe314610a3357600080fd5b806395d89b411461094f5780639a7a23d6146109645780639c3b4fdc146109845780639fccce321461099a57600080fd5b80638ea5220f116101d75780638ea5220f146108c95780638f8b041e146108e95780639213691314610919578063924de9b71461092f57600080fd5b80637bce5a04146108665780638a8c523c1461087c5780638b701d68146108915780638da5cb5b146108ab57600080fd5b806327c8f8351161030357806351f205e41161029657806370a082311161026557806370a08231146107c6578063715018a6146107fc578063751039fc146108115780637571336a1461082657806375f0a8741461084657600080fd5b806351f205e41461075b57806363abb284146107705780636a486a8e146107905780636ddd1713146107a657600080fd5b806341b319b2116102d257806341b319b2146106a757806349bd5a5e146106d45780634a62bb65146107085780634fbee1931461072257600080fd5b806327c8f835146106355780632e6ed7ef1461064b578063313ce5671461066b578063395093511461068757600080fd5b806319c1f7a8116103865780631e13b4e0116103555780631e13b4e0146105b35780631f3fed8f146105c95780631fe70a98146105df5780632307b441146105f557806323b872dd1461061557600080fd5b806319c1f7a8146105515780631a221dbb146105675780631a8145bb1461057d5780631cd348c01461059357600080fd5b806310d5de53116103c257806310d5de53146104a05780631694505e146104d057806318160ddd1461051c5780631816467f1461053157600080fd5b806306fdde03146103ff578063095ea7b31461042a5780630b166d501461045a578063106b5da11461047e57600080fd5b366103fa57005b600080fd5b34801561040b57600080fd5b50610414610c68565b6040516104219190613076565b60405180910390f35b34801561043657600080fd5b5061044a6104453660046130e3565b610cfa565b6040519015158152602001610421565b34801561046657600080fd5b50610470601c5481565b604051908152602001610421565b34801561048a57600080fd5b5061049e61049936600461310f565b610d11565b005b3480156104ac57600080fd5b5061044a6104bb366004613128565b60266020526000908152604090205460ff1681565b3480156104dc57600080fd5b506105047f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610421565b34801561052857600080fd5b50600254610470565b34801561053d57600080fd5b5061049e61054c366004613128565b610df7565b34801561055d57600080fd5b5061047060245481565b34801561057357600080fd5b5061047060185481565b34801561058957600080fd5b50610470601b5481565b34801561059f57600080fd5b50600754610504906001600160a01b031681565b3480156105bf57600080fd5b5061047060205481565b3480156105d557600080fd5b50610470601a5481565b3480156105eb57600080fd5b5061047060135481565b34801561060157600080fd5b5061044a61061036600461321b565b610e7e565b34801561062157600080fd5b5061044a6106303660046132dd565b6110be565b34801561064157600080fd5b5061050461dead81565b34801561065757600080fd5b5061049e61066636600461331e565b61111d565b34801561067757600080fd5b5060405160128152602001610421565b34801561069357600080fd5b5061044a6106a23660046130e3565b6111d6565b3480156106b357600080fd5b506104706106c2366004613128565b601e6020526000908152604090205481565b3480156106e057600080fd5b506105047f0000000000000000000000009282ac76d2c3826c5cbcdfbe59b6e591ef3f9ecf81565b34801561071457600080fd5b50600c5461044a9060ff1681565b34801561072e57600080fd5b5061044a61073d366004613128565b6001600160a01b031660009081526025602052604090205460ff1690565b34801561076757600080fd5b5061049e61120c565b34801561077c57600080fd5b5061047061078b366004613128565b611308565b34801561079c57600080fd5b5061047060155481565b3480156107b257600080fd5b50600c5461044a9062010000900460ff1681565b3480156107d257600080fd5b506104706107e1366004613128565b6001600160a01b031660009081526020819052604090205490565b34801561080857600080fd5b5061049e611364565b34801561081d57600080fd5b5061044a6113d8565b34801561083257600080fd5b5061049e610841366004613360565b611422565b34801561085257600080fd5b50600654610504906001600160a01b031681565b34801561087257600080fd5b5061047060115481565b34801561088857600080fd5b5061049e611477565b34801561089d57600080fd5b5060215461044a9060ff1681565b3480156108b757600080fd5b506005546001600160a01b0316610504565b3480156108d557600080fd5b50600854610504906001600160a01b031681565b3480156108f557600080fd5b5061044a610904366004613128565b60226020526000908152604090205460ff1681565b34801561092557600080fd5b5061047060165481565b34801561093b57600080fd5b5061049e61094a366004613395565b6114b4565b34801561095b57600080fd5b506104146114fa565b34801561097057600080fd5b5061049e61097f366004613360565b611509565b34801561099057600080fd5b5061047060145481565b3480156109a657600080fd5b50610470601d5481565b3480156109bc57600080fd5b5061047060195481565b3480156109d257600080fd5b5061044a6109e13660046130e3565b6115e9565b3480156109f257600080fd5b5061044a610a013660046130e3565b611638565b348015610a1257600080fd5b50610470610a21366004613128565b601f6020526000908152604090205481565b348015610a3f57600080fd5b5061049e610a4e366004613128565b611645565b348015610a5f57600080fd5b5061044a610a6e366004613128565b60276020526000908152604090205460ff1681565b348015610a8f57600080fd5b50600c5461044a90610100900460ff1681565b348015610aae57600080fd5b5061049e610abd366004613360565b6116cc565b348015610ace57600080fd5b50600f5461044a9060ff1681565b348015610ae857600080fd5b5061047060095481565b348015610afe57600080fd5b5061044a610b0d36600461310f565b611755565b348015610b1e57600080fd5b5061047060105481565b348015610b3457600080fd5b50610470610b433660046133b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610b7a57600080fd5b50610470600a5481565b348015610b9057600080fd5b5061049e610b9f36600461331e565b6118ac565b348015610bb057600080fd5b5061044a61195f565b348015610bc557600080fd5b5061047060125481565b348015610bdb57600080fd5b5061049e610bea366004613128565b61199c565b348015610bfb57600080fd5b5061047060175481565b348015610c1157600080fd5b50610470610c20366004613128565b60236020526000908152604090205481565b348015610c3e57600080fd5b50610470600b5481565b348015610c5457600080fd5b5061049e610c6336600461310f565b611a87565b606060038054610c77906133e9565b80601f0160208091040260200160405190810160405280929190818152602001828054610ca3906133e9565b8015610cf05780601f10610cc557610100808354040283529160200191610cf0565b820191906000526020600020905b815481529060010190602001808311610cd357829003601f168201915b5050505050905090565b6000610d07338484611ce6565b5060015b92915050565b6005546001600160a01b03163314610d445760405162461bcd60e51b8152600401610d3b90613424565b60405180910390fd5b670de0b6b3a76400006103e8610d5960025490565b610d6490600561346f565b610d6e919061348e565b610d78919061348e565b811015610ddf5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e352560881b6064820152608401610d3b565b610df181670de0b6b3a764000061346f565b60095550565b6005546001600160a01b03163314610e215760405162461bcd60e51b8152600401610d3b90613424565b6008546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6005546000906001600160a01b03163314610eab5760405162461bcd60e51b8152600401610d3b90613424565b600c54610100900460ff1615610f295760405162461bcd60e51b815260206004820152603760248201527f54726164696e6720697320616c7265616479206163746976652c2063616e6e6f60448201527f742061697264726f70206166746572206c61756e63682e0000000000000000006064820152608401610d3b565b8151835114610f7a5760405162461bcd60e51b815260206004820152601e60248201527f617272617973206d757374206265207468652073616d65206c656e67746800006044820152606401610d3b565b60c8835110610fea5760405162461bcd60e51b815260206004820152603660248201527f43616e206f6e6c792061697264726f70203230302077616c6c657473207065726044820152752074786e2064756520746f20676173206c696d69747360501b6064820152608401610d3b565b60005b83518110156110b457600084828151811061100a5761100a6134b0565b602002602001015190506000848381518110611028576110286134b0565b6020908102919091018101516001600160a01b0384166000908152602283526040808220805460ff1916600190811790915560238552818320849055601f9094529020819055915061107b904290611e0b565b6001600160a01b0383166000908152601e602052604090205561109f338383611e4d565b505080806110ac906134c6565b915050610fed565b5060019392505050565b60006110cb848484611e4d565b6110b48433611118856040518060600160405280602881526020016136bf602891396001600160a01b038a166000908152600160209081526040808320338452909152902054919061285f565b611ce6565b6005546001600160a01b031633146111475760405162461bcd60e51b8152600401610d3b90613424565b6011849055601283905560138290556014819055808261116785876134e1565b61117191906134e1565b61117b91906134e1565b6010819055600e11156111d05760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420313425206f72206c6573730000006044820152606401610d3b565b50505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610d079185906111189086611c80565b6005546001600160a01b031633146112365760405162461bcd60e51b8152600401610d3b90613424565b306000908152602081905260409020546002546112559060649061348e565b8110156112ca5760405162461bcd60e51b815260206004820152603e60248201527f43616e206f6e6c792073776170206261636b206966206d6f7265207468616e2060448201527f3125206f6620746f6b656e7320737475636b206f6e20636f6e747261637400006064820152608401610d3b565b6112d2612899565b6040514281527f1b56c383f4f48fc992e45667ea4eabae777b9cca68b516a9562d8cda78f1bb329060200160405180910390a150565b60215460009060ff1615611348576024546001600160a01b038316600090815260236020526040902054610d0b9160649161134291612b6b565b90612bea565b506001600160a01b03166000908152601f602052604090205490565b6005546001600160a01b0316331461138e5760405162461bcd60e51b8152600401610d3b90613424565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b031633146114055760405162461bcd60e51b8152600401610d3b90613424565b50600c805463ff0000ff19169055600f805460ff19169055600190565b6005546001600160a01b0316331461144c5760405162461bcd60e51b8152600401610d3b90613424565b6001600160a01b03919091166000908152602660205260409020805460ff1916911515919091179055565b6005546001600160a01b031633146114a15760405162461bcd60e51b8152600401610d3b90613424565b600c805462ffff00191662010100179055565b6005546001600160a01b031633146114de5760405162461bcd60e51b8152600401610d3b90613424565b600c8054911515620100000262ff000019909216919091179055565b606060048054610c77906133e9565b6005546001600160a01b031633146115335760405162461bcd60e51b8152600401610d3b90613424565b7f0000000000000000000000009282ac76d2c3826c5cbcdfbe59b6e591ef3f9ecf6001600160a01b0316826001600160a01b031614156115db5760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610d3b565b6115e58282612c2c565b5050565b6000610d073384611118856040518060600160405280602581526020016136e7602591393360009081526001602090815260408083206001600160a01b038d168452909152902054919061285f565b6000610d07338484611e4d565b6005546001600160a01b0316331461166f5760405162461bcd60e51b8152600401610d3b90613424565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146116f65760405162461bcd60e51b8152600401610d3b90613424565b6001600160a01b038216600081815260256020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546000906001600160a01b031633146117825760405162461bcd60e51b8152600401610d3b90613424565b620186a061178f60025490565b61179a90600161346f565b6117a4919061348e565b8210156118115760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610d3b565b6103e861181d60025490565b61182890600561346f565b611832919061348e565b82111561189e5760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610d3b565b50600a81905560015b919050565b6005546001600160a01b031633146118d65760405162461bcd60e51b8152600401610d3b90613424565b601684905560178390556018829055601981905580826118f685876134e1565b61190091906134e1565b61190a91906134e1565b6015819055600e11156111d05760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420313425206f72206c6573730000006044820152606401610d3b565b6005546000906001600160a01b0316331461198c5760405162461bcd60e51b8152600401610d3b90613424565b50600f805460ff19169055600190565b6005546001600160a01b031633146119c65760405162461bcd60e51b8152600401610d3b90613424565b6001600160a01b038116611a2b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610d3b565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314611ab15760405162461bcd60e51b8152600401610d3b90613424565b6040805160028082526060820183526000926020830190803683370190505090507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2b57600080fd5b505afa158015611b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6391906134f9565b81600081518110611b7657611b766134b0565b60200260200101906001600160a01b031690816001600160a01b0316815250503081600181518110611baa57611baa6134b0565b6001600160a01b03928316602091820292909201015260405163b6f9de9560e01b81527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d9091169063b6f9de95908490611c1190600090869061dead90429060040161355a565b6000604051808303818588803b158015611c2a57600080fd5b505af1158015611c3e573d6000803e3d6000fd5b50505050507fa017c1567cfcdd2d750a8c01e39fe2a846bcebc293c7d078477014d68482056882604051611c7491815260200190565b60405180910390a15050565b600080611c8d83856134e1565b905083811015611cdf5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610d3b565b9392505050565b6001600160a01b038316611d485760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610d3b565b6001600160a01b038216611da95760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610d3b565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6000611cdf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061285f565b6001600160a01b038316611e735760405162461bcd60e51b8152600401610d3b9061358f565b6001600160a01b038216611e995760405162461bcd60e51b8152600401610d3b906135d4565b80611eaf57611eaa83836000612c80565b505050565b600c5460ff1615612245576005546001600160a01b03848116911614801590611ee657506005546001600160a01b03838116911614155b8015611efa57506001600160a01b03821615155b8015611f1157506001600160a01b03821661dead14155b8015611f275750600554600160a01b900460ff16155b1561224557600c54610100900460ff16611fbf576001600160a01b03831660009081526025602052604090205460ff1680611f7a57506001600160a01b03821660009081526025602052604090205460ff165b611fbf5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610d3b565b600c546301000000900460ff168015611ff057506001600160a01b03831660009081526027602052604090205460ff165b1561204757600d543a11156120475760405162461bcd60e51b815260206004820152601860248201527f4761732070726963652065786365656473206c696d69742e00000000000000006044820152606401610d3b565b600f5460ff161561218e576005546001600160a01b038381169116148015906120a257507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b80156120e057507f0000000000000000000000009282ac76d2c3826c5cbcdfbe59b6e591ef3f9ecf6001600160a01b0316826001600160a01b031614155b1561218e57326000908152600e6020526040902054431161217b5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610d3b565b326000908152600e602052604090204390555b6001600160a01b03821660009081526027602052604090205460ff1680156121cf57506001600160a01b03831660009081526026602052604090205460ff16155b15612245576009548111156122455760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610d3b565b60215460ff16156124d0574260205411612268576021805460ff191690556124d0565b6001600160a01b0383166000908152602081815260408083205460229092529091205460ff1680156122ba57506001600160a01b0384166000908152601f60205260409020546122b88284611e0b565b105b156124ce576001600160a01b0384166000908152601e602052604090205442108015906122f657506020546122f290620d2f00611e0b565b4210155b6123685760405162461bcd60e51b815260206004820152603d60248201527f5f7472616e736665723a3a20506c6561736520726561642074686520636f6e7460448201527f7261637420666f7220796f7572206e6578742073616c6520646174652e0000006064820152608401610d3b565b600061237385611308565b6001600160a01b0386166000908152601f6020526040812054919250906123a79084906123a1908790611c80565b90611e0b565b9050818111156124455760405162461bcd60e51b815260206004820152605e60248201527f5f7472616e736665723a3a204d6179206e6f742073656c6c206d6f726520746860448201527f616e20616c6c6f636174656420746f6b656e7320696e20612073696e676c652060648201527f64617920756e74696c20746865204c696d6974206973206c69667465642e0000608482015260a401610d3b565b6001600160a01b0386166000908152601f60205260409020546124689082611e0b565b6001600160a01b0387166000908152601f60205260409020556064612491836113428484612b6b565b61249e906201518061346f565b6124a8919061348e565b6124b290426134e1565b6001600160a01b0387166000908152601e602052604090205550505b505b30600090815260208190526040902054600a54811080159081906124fc5750600c5462010000900460ff165b80156125125750600554600160a01b900460ff16155b801561253757506001600160a01b03851660009081526027602052604090205460ff16155b801561255c57506001600160a01b03851660009081526025602052604090205460ff16155b801561258157506001600160a01b03841660009081526025602052604090205460ff16155b156125af576005805460ff60a01b1916600160a01b1790556125a1612899565b6005805460ff60a01b191690555b6005546001600160a01b03861660009081526025602052604090205460ff600160a01b9092048216159116806125fd57506001600160a01b03851660009081526025602052604090205460ff165b15612606575060005b6000811561284b576001600160a01b03861660009081526027602052604090205460ff16801561263857506000601554115b1561272057612657606461134260155488612b6b90919063ffffffff16565b90506015546017548261266a919061346f565b612674919061348e565b601b600082825461268591906134e1565b909155505060155460185461269a908361346f565b6126a4919061348e565b601c60008282546126b591906134e1565b90915550506015546019546126ca908361346f565b6126d4919061348e565b601d60008282546126e591906134e1565b90915550506015546016546126fa908361346f565b612704919061348e565b601a600082825461271591906134e1565b9091555061282d9050565b6001600160a01b03871660009081526027602052604090205460ff16801561274a57506000601054115b1561282d57612769606461134260105488612b6b90919063ffffffff16565b90506010546012548261277c919061346f565b612786919061348e565b601b600082825461279791906134e1565b90915550506010546013546127ac908361346f565b6127b6919061348e565b601c60008282546127c791906134e1565b90915550506010546014546127dc908361346f565b6127e6919061348e565b601d60008282546127f791906134e1565b909155505060105460115461280c908361346f565b612816919061348e565b601a600082825461282791906134e1565b90915550505b801561283e5761283e873083612c80565b6128488186613617565b94505b612856878787612c80565b50505050505050565b600081848411156128835760405162461bcd60e51b8152600401610d3b9190613076565b5060006128908486613617565b95945050505050565b3060009081526020819052604081205490506000601d54601c54601a54601b546128c391906134e1565b6128cd91906134e1565b6128d791906134e1565b90508115806128e4575080155b156128ed575050565b6000600282601b5485612900919061346f565b61290a919061348e565b612914919061348e565b905060006129228483611e0b565b90504761292e82612d89565b600061293a4783611e0b565b9050600061295786611342601a5485612b6b90919063ffffffff16565b9050600061297487611342601d5486612b6b90919063ffffffff16565b9050600061299188611342601c5487612b6b90919063ffffffff16565b9050600081836129a18688613617565b6129ab9190613617565b6129b59190613617565b6000601b819055601a819055601c819055601d81905560065460405192935090916001600160a01b039091169086908381818185875af1925050503d8060008114612a1c576040519150601f19603f3d011682016040523d82523d6000602084013e612a21565b606091505b50506008546040519192506001600160a01b0316908590600081818185875af1925050503d8060008114612a71576040519150601f19603f3d011682016040523d82523d6000602084013e612a76565b606091505b50909150508815801590612a8a5750600082115b15612add57612a998983612f58565b601b54604080518a81526020810185905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b601354158015612aed5750601854155b8015612b015750670de0b6b3a76400004710155b15612b5e576006546040516001600160a01b03909116904790600081818185875af1925050503d8060008114612b53576040519150601f19603f3d011682016040523d82523d6000602084013e612b58565b606091505b50909150505b5050505050505050505050565b600082612b7a57506000610d0b565b6000612b86838561346f565b905082612b93858361348e565b14611cdf5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610d3b565b6000611cdf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613048565b6001600160a01b038216600081815260276020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b038316612ca65760405162461bcd60e51b8152600401610d3b9061358f565b6001600160a01b038216612ccc5760405162461bcd60e51b8152600401610d3b906135d4565b612d0981604051806060016040528060268152602001613699602691396001600160a01b038616600090815260208190526040902054919061285f565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612d389082611c80565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101611dfe565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612dbe57612dbe6134b0565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015612e3757600080fd5b505afa158015612e4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6f91906134f9565b81600181518110612e8257612e826134b0565b60200260200101906001600160a01b031690816001600160a01b031681525050612ecd307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611ce6565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612f2290859060009086903090429060040161362e565b600060405180830381600087803b158015612f3c57600080fd5b505af1158015612f50573d6000803e3d6000fd5b505050505050565b612f83307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611ce6565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b15801561300857600080fd5b505af115801561301c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613041919061366a565b5050505050565b600081836130695760405162461bcd60e51b8152600401610d3b9190613076565b506000612890848661348e565b600060208083528351808285015260005b818110156130a357858101830151858201604001528201613087565b818111156130b5576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b03811681146130e057600080fd5b50565b600080604083850312156130f657600080fd5b8235613101816130cb565b946020939093013593505050565b60006020828403121561312157600080fd5b5035919050565b60006020828403121561313a57600080fd5b8135611cdf816130cb565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561318457613184613145565b604052919050565b600067ffffffffffffffff8211156131a6576131a6613145565b5060051b60200190565b600082601f8301126131c157600080fd5b813560206131d66131d18361318c565b61315b565b82815260059290921b840181019181810190868411156131f557600080fd5b8286015b8481101561321057803583529183019183016131f9565b509695505050505050565b6000806040838503121561322e57600080fd5b823567ffffffffffffffff8082111561324657600080fd5b818501915085601f83011261325a57600080fd5b8135602061326a6131d18361318c565b82815260059290921b8401810191818101908984111561328957600080fd5b948201945b838610156132b05785356132a1816130cb565b8252948201949082019061328e565b965050860135925050808211156132c657600080fd5b506132d3858286016131b0565b9150509250929050565b6000806000606084860312156132f257600080fd5b83356132fd816130cb565b9250602084013561330d816130cb565b929592945050506040919091013590565b6000806000806080858703121561333457600080fd5b5050823594602084013594506040840135936060013592509050565b803580151581146118a757600080fd5b6000806040838503121561337357600080fd5b823561337e816130cb565b915061338c60208401613350565b90509250929050565b6000602082840312156133a757600080fd5b611cdf82613350565b600080604083850312156133c357600080fd5b82356133ce816130cb565b915060208301356133de816130cb565b809150509250929050565b600181811c908216806133fd57607f821691505b6020821081141561341e57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561348957613489613459565b500290565b6000826134ab57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006000198214156134da576134da613459565b5060010190565b600082198211156134f4576134f4613459565b500190565b60006020828403121561350b57600080fd5b8151611cdf816130cb565b600081518084526020808501945080840160005b8381101561354f5781516001600160a01b03168752958201959082019060010161352a565b509495945050505050565b8481526080602082015260006135736080830186613516565b6001600160a01b03949094166040830152506060015292915050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561362957613629613459565b500390565b85815284602082015260a06040820152600061364d60a0830186613516565b6001600160a01b0394909416606083015250608001529392505050565b60008060006060848603121561367f57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122054140c7fb53781c84bb13156619904e3d5cffbb83e53c9783c5b7f1409db21b864736f6c63430008090033
[ 0, 21, 4, 7, 6, 11, 13, 5 ]
0xF3b4f244f73891675b35A9D5D90a2564679A0811
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "./interfaces/IWnD.sol"; import "./interfaces/ITower.sol"; import "./interfaces/ITraits.sol"; import "./interfaces/IGP.sol"; contract WnD is IWnD, ERC721Enumerable, Ownable, Pausable { struct LastWrite { uint64 time; uint64 blockNum; } // max number of tokens that can be minted: 60000 in production uint256 public maxTokens; // number of tokens that can be claimed for a fee: 15,000 uint256 public PAID_TOKENS; // number of tokens have been minted so far uint16 public override minted; uint16 private numWizards; uint16 private numDragons; uint16 private numWizardsStolen; uint16 private numDragonsStolen; uint16 private numWizardsBurned; uint16 private numDragonsBurned; // mapping from tokenId to a struct containing the token's traits mapping(uint256 => WizardDragon) public override tokenTraits; // mapping from hashed(tokenTrait) to the tokenId it's associated with // used to ensure there are no duplicates mapping(uint256 => uint256) public existingCombinations; // Tracks the last block and timestamp that a caller has written to state. // Disallow some access to functions if they occur while a change is being written. mapping(address => LastWrite) private lastWrite; // list of probabilities for each trait type // 0 - 9 are associated with Wizard, 10 - 18 are associated with Dragons uint8[][18] public rarities; // list of aliases for Walker's Alias algorithm // 0 - 9 are associated with Wizard, 10 - 18 are associated with Dragons uint8[][18] public aliases; // reference to the Tower contract to allow transfers to it without approval ITower public tower; // reference to Traits ITraits public traits; // address => allowedToCallFunctions mapping(address => bool) private admins; constructor(uint256 _maxTokens) ERC721("Contract2", "Contract2") { maxTokens = _maxTokens; PAID_TOKENS = _maxTokens / 4; _pause(); // A.J. Walker's Alias Algorithm // Wizards // body rarities[0] = [80, 150, 200, 250, 255]; aliases[0] = [4, 4, 4, 4, 4]; // head rarities[1] = [150, 40, 240, 90, 115, 135, 40, 199, 100]; aliases[1] = [3, 7, 4, 0, 5, 6, 8, 5, 0]; // spell rarities[2] = [255, 135, 60, 130, 190, 156, 250, 120, 60, 25, 190]; aliases[2] = [0, 0, 0, 6, 6, 0, 0, 0, 6, 8, 0]; // eyes rarities[3] = [221, 100, 181, 140, 224, 147, 84, 228, 140, 224, 250, 160, 241, 207, 173, 84, 254]; aliases[3] = [1, 2, 5, 0, 1, 7, 1, 10, 5, 10, 11, 12, 13, 14, 16, 11, 0]; // neck rarities[4] = [175, 100, 40, 250, 115, 100, 80, 110, 180, 255, 210, 180]; aliases[4] = [3, 0, 4, 1, 11, 7, 8, 10, 9, 9, 8, 8]; // mouth rarities[5] = [80, 225, 220, 35, 100, 240, 70, 160, 175, 217, 175, 60]; aliases[5] = [1, 2, 5, 8, 2, 8, 8, 9, 9, 10, 7, 10]; // neck rarities[6] = [255]; aliases[6] = [0]; // wand rarities[7] = [243, 189, 50, 30, 55, 180, 80, 90, 155, 30, 222, 255]; aliases[7] = [1, 7, 5, 2, 11, 11, 0, 10, 0, 0, 11, 3]; // rankIndex rarities[8] = [255]; aliases[8] = [0]; // Dragons // body rarities[9] = [100, 80, 177, 199, 255, 40, 211, 177, 25, 230, 90, 130, 199, 230]; aliases[9] = [4, 3, 3, 4, 4, 13, 9, 1, 2, 5, 13, 0, 6, 12]; // head rarities[10] = [255]; aliases[10] = [0]; // spell rarities[11] = [255]; aliases[11] = [0]; // eyes rarities[12] = [90, 40, 219, 80, 183, 225, 40, 120, 60, 220]; aliases[12] = [1, 8, 3, 2, 5, 6, 5, 9, 4, 3]; // nose rarities[13] = [255]; aliases[13] = [0]; // mouth rarities[14] = [239, 244, 255, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234]; aliases[14] = [1, 2, 2, 0, 2, 2, 9, 0, 5, 4, 4, 4, 4, 4]; // tails rarities[15] = [80, 200, 144, 145, 80, 140, 120]; aliases[15] = [1, 8, 0, 0, 3, 0, 3]; // wand rarities[16] = [255]; aliases[16] = [0]; // rankIndex rarities[17] = [14, 155, 80, 255]; aliases[17] = [2, 3, 3, 3]; } /** CRITICAL TO SETUP / MODIFIERS */ modifier requireContractsSet() { require(address(traits) != address(0) && address(tower) != address(0), "Contracts not set"); _; } modifier disallowIfStateIsChanging() { // frens can always call whenever they want :) require(admins[_msgSender()] || lastWrite[tx.origin].blockNum < block.number, "hmmmm what doing?"); _; } function setContracts(address _traits, address _tower) external onlyOwner { traits = ITraits(_traits); tower = ITower(_tower); } /** EXTERNAL */ function getNumWizards() external view disallowIfStateIsChanging returns (uint16) { return numWizards; } function getNumWizardsStolen() external view disallowIfStateIsChanging returns (uint16) { return numWizardsStolen; } function getNumDragons() external view disallowIfStateIsChanging returns (uint16) { return numDragons; } function getNumDragonsStolen() external view disallowIfStateIsChanging returns (uint16) { return numDragonsStolen; } function getNumWizardsBurned() external view disallowIfStateIsChanging returns (uint16) { return numWizardsBurned; } function getNumDragonsBurned() external view disallowIfStateIsChanging returns (uint16) { return numDragonsBurned; } /** * Mint a token - any payment / game logic should be handled in the game contract. * This will just generate random traits and mint a token to a designated address. */ function mint(address recipient, uint256 seed) external override whenNotPaused { require(admins[_msgSender()], "Only admins can call this"); require(minted + 1 <= maxTokens, "All tokens minted"); minted++; generate(minted, seed, lastWrite[tx.origin]); if(tx.origin != recipient && recipient != address(tower)) { // Stolen! if(tokenTraits[minted].isWizard) { numWizardsStolen += 1; } else { numDragonsStolen += 1; } } _safeMint(recipient, minted); } /** * Burn a token - any game logic should be handled before this function. */ function burn(uint256 tokenId) external override whenNotPaused { require(admins[_msgSender()], "Only admins can call this"); require(ownerOf(tokenId) == tx.origin, "Oops you don't own that"); if(tokenTraits[minted].isWizard) { numWizardsBurned += 1; } else { numDragonsBurned += 1; } _burn(tokenId); } function updateOriginAccess() external override { require(admins[_msgSender()], "Only admins can call this"); lastWrite[tx.origin].blockNum = uint64(block.number); lastWrite[tx.origin].time = uint64(block.number); } function transferFrom( address from, address to, uint256 tokenId ) public virtual override(ERC721, IERC721) { // allow admin contracts to be send without approval if(!admins[_msgSender()]) { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); } _transfer(from, to, tokenId); } /** INTERNAL */ /** * generates traits for a specific token, checking to make sure it's unique * @param tokenId the id of the token to generate traits for * @param seed a pseudorandom 256 bit number to derive traits from * @return t - a struct of traits for the given token ID */ function generate(uint256 tokenId, uint256 seed, LastWrite memory lw) internal returns (WizardDragon memory t) { t = selectTraits(seed); if (existingCombinations[structToHash(t)] == 0) { tokenTraits[tokenId] = t; existingCombinations[structToHash(t)] = tokenId; if(t.isWizard) { numWizards += 1; } else { numDragons += 1; } return t; } return generate(tokenId, random(seed, lw.time, lw.blockNum), lw); } /** * uses A.J. Walker's Alias algorithm for O(1) rarity table lookup * ensuring O(1) instead of O(n) reduces mint cost by more than 50% * probability & alias tables are generated off-chain beforehand * @param seed portion of the 256 bit seed to remove trait correlation * @param traitType the trait type to select a trait for * @return the ID of the randomly selected trait */ function selectTrait(uint16 seed, uint8 traitType) internal view returns (uint8) { uint8 trait = uint8(seed) % uint8(rarities[traitType].length); // If a selected random trait probability is selected (biased coin) return that trait if (seed >> 8 < rarities[traitType][trait]) return trait; return aliases[traitType][trait]; } /** * selects the species and all of its traits based on the seed value * @param seed a pseudorandom 256 bit number to derive traits from * @return t - a struct of randomly selected traits */ function selectTraits(uint256 seed) internal view returns (WizardDragon memory t) { t.isWizard = (seed & 0xFFFF) % 10 != 0; uint8 shift = t.isWizard ? 0 : 9; seed >>= 16; t.body = selectTrait(uint16(seed & 0xFFFF), 0 + shift); seed >>= 16; t.head = selectTrait(uint16(seed & 0xFFFF), 1 + shift); seed >>= 16; t.spell = selectTrait(uint16(seed & 0xFFFF), 2 + shift); seed >>= 16; t.eyes = selectTrait(uint16(seed & 0xFFFF), 3 + shift); seed >>= 16; t.neck = selectTrait(uint16(seed & 0xFFFF), 4 + shift); seed >>= 16; t.mouth = selectTrait(uint16(seed & 0xFFFF), 5 + shift); seed >>= 16; t.tail = selectTrait(uint16(seed & 0xFFFF), 6 + shift); seed >>= 16; t.wand = selectTrait(uint16(seed & 0xFFFF), 7 + shift); seed >>= 16; t.rankIndex = selectTrait(uint16(seed & 0xFFFF), 8 + shift); } /** * converts a struct to a 256 bit hash to check for uniqueness * @param s the struct to pack into a hash * @return the 256 bit hash of the struct */ function structToHash(WizardDragon memory s) internal pure returns (uint256) { return uint256(keccak256( abi.encodePacked( s.isWizard, s.body, s.head, s.spell, s.eyes, s.neck, s.mouth, s.tail, s.wand, s.rankIndex ) )); } /** * generates a pseudorandom number for picking traits. Uses point in time randomization to prevent abuse. */ function random(uint256 seed, uint64 timestamp, uint64 blockNumber) internal view returns (uint256) { return uint256(keccak256(abi.encodePacked( tx.origin, blockhash(blockNumber > 1 ? blockNumber - 2 : blockNumber),// Different block than WnDGame to ensure if needing to re-randomize that it goes down a different path timestamp, seed ))); } /** READ */ function getMaxTokens() external view override returns (uint256) { return maxTokens; } function getPaidTokens() external view override returns (uint256) { return PAID_TOKENS; } /** ADMIN */ /** * allows owner to withdraw funds from minting */ function withdraw() external onlyOwner { payable(owner()).transfer(address(this).balance); } /** * updates the number of tokens for sale */ function setPaidTokens(uint256 _paidTokens) external onlyOwner { PAID_TOKENS = uint16(_paidTokens); } /** * enables owner to pause / unpause minting */ function setPaused(bool _paused) external requireContractsSet onlyOwner { if (_paused) _pause(); else _unpause(); } /** * enables an address to mint / burn * @param addr the address to enable */ function addAdmin(address addr) external onlyOwner { admins[addr] = true; } /** * disables an address from minting / burning * @param addr the address to disbale */ function removeAdmin(address addr) external onlyOwner { admins[addr] = false; } /** Traits */ function getTokenTraits(uint256 tokenId) external view override disallowIfStateIsChanging returns (WizardDragon memory) { return tokenTraits[tokenId]; } function tokenURI(uint256 tokenId) public view override disallowIfStateIsChanging returns (string memory) { require(_exists(tokenId), "Token ID does not exist"); return traits.tokenURI(tokenId); } /** OVERRIDES FOR SAFETY */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override(ERC721Enumerable, IERC721Enumerable) disallowIfStateIsChanging returns (uint256) { // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWrite[owner].blockNum < block.number, "hmmmm what doing?"); return super.tokenOfOwnerByIndex(owner, index); } function balanceOf(address owner) public view virtual override(ERC721, IERC721) disallowIfStateIsChanging returns (uint256) { // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWrite[owner].blockNum < block.number, "hmmmm what doing?"); return super.balanceOf(owner); } function ownerOf(uint256 tokenId) public view virtual override(ERC721, IERC721) disallowIfStateIsChanging returns (address) { address addr = super.ownerOf(tokenId); // Y U checking on this address in the same block it's being modified... hmmmm require(admins[_msgSender()] || lastWrite[addr].blockNum < block.number, "hmmmm what doing?"); return addr; } } // 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 "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT 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 LICENSE pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; interface IWnD is IERC721Enumerable { // game data storage struct WizardDragon { bool isWizard; uint8 body; uint8 head; uint8 spell; uint8 eyes; uint8 neck; uint8 mouth; uint8 wand; uint8 tail; uint8 rankIndex; } function minted() external returns (uint16); function updateOriginAccess() external; function mint(address recipient, uint256 seed) external; function burn(uint256 tokenId) external; function getMaxTokens() external view returns (uint256); function getPaidTokens() external view returns (uint256); function getTokenTraits(uint256 tokenId) external view returns (WizardDragon memory); function tokenTraits(uint256 tokenId) external view returns (bool a, uint8 b, uint8 c, uint8 d, uint8 e, uint8 f, uint8 g, uint8 h, uint8 i, uint8 j); } // SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.0; interface ITower { function addManyToTowerAndFlight(address account, uint16[] calldata tokenIds) external; function randomDragonOwner(uint256 seed) external view returns (address); } // SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.0; interface ITraits { function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.0; interface IGP { function mint(address to, uint256 amount) external; function burn(address from, uint256 amount) external; function updateOriginAccess() external; function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./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 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); }
0x608060405234801561001057600080fd5b50600436106102955760003560e01c80636352211e11610167578063a22cb465116100ce578063e05c57bf11610087578063e05c57bf14610589578063e1fc334f14610662578063e32368cd14610675578063e83157421461067d578063e985e9c514610686578063f2fde38b146106c257600080fd5b8063a22cb46514610521578063b88d4fde14610534578063c084f54014610547578063c87b56dd14610550578063ca14df4f14610563578063d8952a491461057657600080fd5b80638da5cb5b116101205780638da5cb5b146104b857806394e56847146104c957806395d89b41146104e95780639c47ee3b146104f1578063a050d07d146104f9578063a1b8f3741461050157600080fd5b80636352211e146104675780636abcded11461047a578063704802751461048257806370a0823114610495578063715018a6146104a8578063851ad4d6146104b057600080fd5b806333df4b2c1161020b57806342842e0e116101c457806342842e0e1461040657806342966c68146104195780634f02c4201461042c5780634f6ccce71461043a5780635c975abb1461044d5780635ffa25b61461045f57600080fd5b806333df4b2c146103985780633431a753146103bd57806336838391146103d05780633ccfd60b146103e35780634018b1f8146103eb57806340c10f19146103f357600080fd5b806316c38b3c1161025d57806316c38b3c146103325780631785f53c1461034557806318160ddd14610358578063205ae8a41461036a57806323b872dd146103725780632f745c591461038557600080fd5b806301ffc9a71461029a57806303dd0797146102c257806306fdde03146102dd578063081812fc146102f2578063095ea7b31461031d575b600080fd5b6102ad6102a8366004612d8b565b6106d5565b60405190151581526020015b60405180910390f35b6102ca610700565b60405161ffff90911681526020016102b9565b6102e5610774565b6040516102b99190612f76565b610305610300366004612e35565b610806565b6040516001600160a01b0390911681526020016102b9565b61033061032b366004612d48565b61089b565b005b610330610340366004612d71565b6109b1565b610330610353366004612bf6565b610a58565b6008545b6040519081526020016102b9565b6102ca610aa3565b610330610380366004612c42565b610b0e565b61035c610393366004612d48565b610b56565b6103ab6103a6366004612e4d565b610c22565b60405160ff90911681526020016102b9565b6103306103cb366004612e35565b610c68565b6103ab6103de366004612e4d565b610c9b565b610330610cab565b600c5461035c565b610330610401366004612d48565b610d0e565b610330610414366004612c42565b610f14565b610330610427366004612e35565b610f2f565b600d546102ca9061ffff1681565b61035c610448366004612e35565b611089565b600a54600160a01b900460ff166102ad565b6102ca61112a565b610305610475366004612e35565b611195565b600b5461035c565b610330610490366004612bf6565b611266565b61035c6104a3366004612bf6565b6112b4565b610330611378565b6102ca6113ae565b600a546001600160a01b0316610305565b6104dc6104d7366004612e35565b61141a565b6040516102b991906130ed565b6102e561152d565b61033061153c565b6102ca6115b5565b61035c61050f366004612e35565b600f6020526000908152604090205481565b61033061052f366004612d1f565b61161f565b610330610542366004612c7d565b6116e4565b61035c600c5481565b6102e561055e366004612e35565b61171c565b603554610305906001600160a01b031681565b610330610584366004612c10565b61185c565b610607610597366004612e35565b600e6020526000908152604090205460ff808216916101008104821691620100008204811691630100000081048216916401000000008204811691650100000000008104821691600160301b8204811691600160381b8104821691600160401b8204811691600160481b9004168a565b604080519a15158b5260ff998a1660208c0152978916978a01979097529487166060890152928616608088015290851660a0870152841660c0860152831660e0850152821661010084015216610120820152610140016102b9565b603654610305906001600160a01b031681565b6102ca6118b4565b61035c600b5481565b6102ad610694366004612c10565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6103306106d0366004612bf6565b61191f565b60006001600160e01b0319821663780e9d6360e01b14806106fa57506106fa826119b7565b92915050565b3360009081526037602052604081205460ff168061073d57503260009081526010602052604090205443600160401b9091046001600160401b0316105b6107625760405162461bcd60e51b815260040161075990613012565b60405180910390fd5b50600d54600160601b900461ffff1690565b606060008054610783906132d6565b80601f01602080910402602001604051908101604052809291908181526020018280546107af906132d6565b80156107fc5780601f106107d1576101008083540402835291602001916107fc565b820191906000526020600020905b8154815290600101906020018083116107df57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661087f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610759565b506000908152600460205260409020546001600160a01b031690565b60006108a682611a07565b9050806001600160a01b0316836001600160a01b031614156109145760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610759565b336001600160a01b038216148061093057506109308133610694565b6109a25760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610759565b6109ac8383611a7e565b505050565b6036546001600160a01b0316158015906109d557506035546001600160a01b031615155b610a155760405162461bcd60e51b815260206004820152601160248201527010dbdb9d1c9858dd1cc81b9bdd081cd95d607a1b6044820152606401610759565b600a546001600160a01b03163314610a3f5760405162461bcd60e51b815260040161075990613067565b8015610a5057610a4d611aec565b50565b610a4d611b6e565b600a546001600160a01b03163314610a825760405162461bcd60e51b815260040161075990613067565b6001600160a01b03166000908152603760205260409020805460ff19169055565b3360009081526037602052604081205460ff1680610ae057503260009081526010602052604090205443600160401b9091046001600160401b0316105b610afc5760405162461bcd60e51b815260040161075990613012565b50600d54600160501b900461ffff1690565b3360009081526037602052604090205460ff16610b4b57610b2f3382611bf2565b610b4b5760405162461bcd60e51b81526004016107599061309c565b6109ac838383611ce9565b3360009081526037602052604081205460ff1680610b9357503260009081526010602052604090205443600160401b9091046001600160401b0316105b610baf5760405162461bcd60e51b815260040161075990613012565b3360009081526037602052604090205460ff1680610bf557506001600160a01b03831660009081526010602052604090205443600160401b9091046001600160401b0316105b610c115760405162461bcd60e51b815260040161075990613012565b610c1b8383611e94565b9392505050565b60118260128110610c3257600080fd5b018181548110610c4157600080fd5b9060005260206000209060209182820401919006915091509054906101000a900460ff1681565b600a546001600160a01b03163314610c925760405162461bcd60e51b815260040161075990613067565b61ffff16600c55565b60238260128110610c3257600080fd5b600a546001600160a01b03163314610cd55760405162461bcd60e51b815260040161075990613067565b600a546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610a4d573d6000803e3d6000fd5b600a54600160a01b900460ff1615610d385760405162461bcd60e51b81526004016107599061303d565b3360009081526037602052604090205460ff16610d675760405162461bcd60e51b815260040161075990612fdb565b600b54600d54610d7c9061ffff166001613208565b61ffff161115610dc25760405162461bcd60e51b8152602060048201526011602482015270105b1b081d1bdad95b9cc81b5a5b9d1959607a1b6044820152606401610759565b600d805461ffff16906000610dd683613311565b82546101009290920a61ffff818102199093169183160217909155600d54326000908152601060209081526040918290208251808401909352546001600160401b038082168452600160401b9091041690820152610e3993509116908390611f2a565b50326001600160a01b03831614801590610e6157506035546001600160a01b03838116911614155b15610efe57600d5461ffff166000908152600e602052604090205460ff1615610ec3576001600d60068282829054906101000a900461ffff16610ea49190613208565b92506101000a81548161ffff021916908361ffff160217905550610efe565b6001600d60088282829054906101000a900461ffff16610ee39190613208565b92506101000a81548161ffff021916908361ffff1602179055505b600d54610f1090839061ffff1661212b565b5050565b6109ac838383604051806020016040528060008152506116e4565b600a54600160a01b900460ff1615610f595760405162461bcd60e51b81526004016107599061303d565b3360009081526037602052604090205460ff16610f885760405162461bcd60e51b815260040161075990612fdb565b32610f9282611195565b6001600160a01b031614610fe85760405162461bcd60e51b815260206004820152601760248201527f4f6f707320796f7520646f6e2774206f776e20746861740000000000000000006044820152606401610759565b600d5461ffff166000908152600e602052604090205460ff1615611045576001600d600a8282829054906101000a900461ffff166110269190613208565b92506101000a81548161ffff021916908361ffff160217905550611080565b6001600d600c8282829054906101000a900461ffff166110659190613208565b92506101000a81548161ffff021916908361ffff1602179055505b610a4d81612145565b600061109460085490565b82106110f75760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610759565b6008828154811061111857634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b3360009081526037602052604081205460ff168061116757503260009081526010602052604090205443600160401b9091046001600160401b0316105b6111835760405162461bcd60e51b815260040161075990613012565b50600d54600160301b900461ffff1690565b3360009081526037602052604081205460ff16806111d257503260009081526010602052604090205443600160401b9091046001600160401b0316105b6111ee5760405162461bcd60e51b815260040161075990613012565b60006111f983611a07565b3360009081526037602052604090205490915060ff168061124257506001600160a01b03811660009081526010602052604090205443600160401b9091046001600160401b0316105b61125e5760405162461bcd60e51b815260040161075990613012565b90505b919050565b600a546001600160a01b031633146112905760405162461bcd60e51b815260040161075990613067565b6001600160a01b03166000908152603760205260409020805460ff19166001179055565b3360009081526037602052604081205460ff16806112f157503260009081526010602052604090205443600160401b9091046001600160401b0316105b61130d5760405162461bcd60e51b815260040161075990613012565b3360009081526037602052604090205460ff168061135357506001600160a01b03821660009081526010602052604090205443600160401b9091046001600160401b0316105b61136f5760405162461bcd60e51b815260040161075990613012565b6106fa826121ec565b600a546001600160a01b031633146113a25760405162461bcd60e51b815260040161075990613067565b6113ac6000612273565b565b3360009081526037602052604081205460ff16806113eb57503260009081526010602052604090205443600160401b9091046001600160401b0316105b6114075760405162461bcd60e51b815260040161075990613012565b50600d54640100000000900461ffff1690565b611422612b7b565b3360009081526037602052604090205460ff168061145f57503260009081526010602052604090205443600160401b9091046001600160401b0316105b61147b5760405162461bcd60e51b815260040161075990613012565b506000908152600e6020908152604091829020825161014081018452905460ff808216151583526101008083048216948401949094526201000082048116948301949094526301000000810484166060830152640100000000810484166080830152650100000000008104841660a0830152600160301b8104841660c0830152600160381b8104841660e0830152600160401b8104841692820192909252600160481b90910490911661012082015290565b606060018054610783906132d6565b3360009081526037602052604090205460ff1661156b5760405162461bcd60e51b815260040161075990612fdb565b32600090815260106020526040902080546fffffffffffffffffffffffffffffffff1916600160401b436001600160401b031690810267ffffffffffffffff191691909117179055565b3360009081526037602052604081205460ff16806115f257503260009081526010602052604090205443600160401b9091046001600160401b0316105b61160e5760405162461bcd60e51b815260040161075990613012565b50600d5462010000900461ffff1690565b6001600160a01b0382163314156116785760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610759565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6116ee3383611bf2565b61170a5760405162461bcd60e51b81526004016107599061309c565b611716848484846122c5565b50505050565b3360009081526037602052604090205460609060ff168061175c57503260009081526010602052604090205443600160401b9091046001600160401b0316105b6117785760405162461bcd60e51b815260040161075990613012565b6000828152600260205260409020546001600160a01b03166117dc5760405162461bcd60e51b815260206004820152601760248201527f546f6b656e20494420646f6573206e6f742065786973740000000000000000006044820152606401610759565b60365460405163c87b56dd60e01b8152600481018490526001600160a01b039091169063c87b56dd9060240160006040518083038186803b15801561182057600080fd5b505afa158015611834573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106fa9190810190612dc3565b600a546001600160a01b031633146118865760405162461bcd60e51b815260040161075990613067565b603680546001600160a01b039384166001600160a01b03199182161790915560358054929093169116179055565b3360009081526037602052604081205460ff16806118f157503260009081526010602052604090205443600160401b9091046001600160401b0316105b61190d5760405162461bcd60e51b815260040161075990613012565b50600d54600160401b900461ffff1690565b600a546001600160a01b031633146119495760405162461bcd60e51b815260040161075990613067565b6001600160a01b0381166119ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610759565b610a4d81612273565b60006001600160e01b031982166380ac58cd60e01b14806119e857506001600160e01b03198216635b5e139f60e01b145b806106fa57506301ffc9a760e01b6001600160e01b03198316146106fa565b6000818152600260205260408120546001600160a01b03168061125e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610759565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611ab382611a07565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600a54600160a01b900460ff1615611b165760405162461bcd60e51b81526004016107599061303d565b600a805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b513390565b6040516001600160a01b03909116815260200160405180910390a1565b600a54600160a01b900460ff16611bbe5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610759565b600a805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611b51565b6000818152600260205260408120546001600160a01b0316611c6b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610759565b6000611c7683611a07565b9050806001600160a01b0316846001600160a01b03161480611cb15750836001600160a01b0316611ca684610806565b6001600160a01b0316145b80611ce157506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611cfc82611a07565b6001600160a01b031614611d645760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610759565b6001600160a01b038216611dc65760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610759565b611dd18383836122f8565b611ddc600082611a7e565b6001600160a01b0383166000908152600360205260408120805460019290611e0590849061326b565b90915550506001600160a01b0382166000908152600360205260408120805460019290611e3390849061322e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611e9f836121ec565b8210611f015760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610759565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b611f32612b7b565b611f3b836123b0565b9050600f6000611f4a8361251e565b8152602001908152602001600020546000141561210e576000848152600e602090815260408083208451815493860151928601516060870151608088015160a089015160c08a015160e08b0151610100808d01516101208e015161ffff19909c1698151561ff0019169890981760ff9a8b169091021763ffff0000191662010000968a169690960263ff0000001916959095176301000000948916949094029390931765ffff0000000019166401000000009288169290920265ff000000000019169190911765010000000000918716919091021767ffff0000000000001916600160301b9186169190910267ff00000000000000191617600160381b918516919091021769ffff00000000000000001916600160401b9184169190910269ff000000000000000000191617600160481b92909316919091029190911790558490600f906120978461251e565b81526020810191909152604001600020558051156120ee576001600d60028282829054906101000a900461ffff166120cf9190613208565b92506101000a81548161ffff021916908361ffff160217905550610c1b565b6001600d60048282829054906101000a900461ffff166120cf9190613208565b611ce1846121258585600001518660200151612582565b84611f2a565b610f10828260405180602001604052806000815250612611565b600061215082611a07565b905061215e816000846122f8565b612169600083611a7e565b6001600160a01b038116600090815260036020526040812080546001929061219290849061326b565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160a01b0382166122575760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610759565b506001600160a01b031660009081526003602052604090205490565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6122d0848484611ce9565b6122dc84848484612644565b6117165760405162461bcd60e51b815260040161075990612f89565b6001600160a01b0383166123535761234e81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612376565b816001600160a01b0316836001600160a01b031614612376576123768382612751565b6001600160a01b03821661238d576109ac816127ee565b826001600160a01b0316826001600160a01b0316146109ac576109ac82826128c7565b6123b8612b7b565b6123c7600a61ffff8416613333565b15158082526000906123da5760096123dd565b60005b60109390931c9290506123fe61ffff84166123f9836000613246565b61290b565b60ff16602083015260109290921c9161242061ffff84166123f9836001613246565b60ff16604083015260109290921c9161244261ffff84166123f9836002613246565b60ff16606083015260109290921c9161246461ffff84166123f9836003613246565b60ff16608083015260109290921c9161248661ffff84166123f9836004613246565b60ff1660a083015260109290921c916124a861ffff84166123f9836005613246565b60ff1660c083015260109290921c916124ca61ffff84166123f9836006613246565b60ff1661010083015260109290921c916124ed61ffff84166123f9836007613246565b60ff1660e083015260109290921c9161250f61ffff84166123f9836008613246565b60ff1661012083015250919050565b80516020808301516040808501516060860151608087015160a088015160c08901516101008a015160e08b01516101208c0151975160009b6125649b909a999101612e9a565b60408051601f19818403018152919052805160209091012092915050565b6000326001836001600160401b03161161259c57826125a7565b6125a7600284613282565b60405160609290921b6bffffffffffffffffffffffff191660208301526001600160401b031640603482015260c084901b6001600160c01b0319166054820152605c8101859052607c0160408051601f198184030181529190528051602090910120949350505050565b61261b8383612a2d565b6126286000848484612644565b6109ac5760405162461bcd60e51b815260040161075990612f89565b60006001600160a01b0384163b1561274657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612688903390899088908890600401612f39565b602060405180830381600087803b1580156126a257600080fd5b505af19250505080156126d2575060408051601f3d908101601f191682019092526126cf91810190612da7565b60015b61272c573d808015612700576040519150601f19603f3d011682016040523d82523d6000602084013e612705565b606091505b5080516127245760405162461bcd60e51b815260040161075990612f89565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611ce1565b506001949350505050565b6000600161275e846121ec565b612768919061326b565b6000838152600760205260409020549091508082146127bb576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906128009060019061326b565b6000838152600960205260408120546008805493945090928490811061283657634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061286557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806128ab57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006128d2836121ec565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b60008060118360ff166012811061293257634e487b7160e01b600052603260045260246000fd5b015461293e9085613347565b905060118360ff166012811061296457634e487b7160e01b600052603260045260246000fd5b018160ff168154811061298757634e487b7160e01b600052603260045260246000fd5b60009182526020918290209181049091015460ff601f9092166101000a90048116600886901c90911610156129bd5790506106fa565b60238360ff16601281106129e157634e487b7160e01b600052603260045260246000fd5b018160ff1681548110612a0457634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff1691505092915050565b6001600160a01b038216612a835760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610759565b6000818152600260205260409020546001600160a01b031615612ae85760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610759565b612af4600083836122f8565b6001600160a01b0382166000908152600360205260408120805460019290612b1d90849061322e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b80356001600160a01b038116811461126157600080fd5b8035801515811461126157600080fd5b600060208284031215612c07578081fd5b610c1b82612bcf565b60008060408385031215612c22578081fd5b612c2b83612bcf565b9150612c3960208401612bcf565b90509250929050565b600080600060608486031215612c56578081fd5b612c5f84612bcf565b9250612c6d60208501612bcf565b9150604084013590509250925092565b60008060008060808587031215612c92578081fd5b612c9b85612bcf565b9350612ca960208601612bcf565b92506040850135915060608501356001600160401b03811115612cca578182fd5b8501601f81018713612cda578182fd5b8035612ced612ce8826131e1565b6131b1565b818152886020838501011115612d01578384fd5b81602084016020830137908101602001929092525092959194509250565b60008060408385031215612d31578182fd5b612d3a83612bcf565b9150612c3960208401612be6565b60008060408385031215612d5a578182fd5b612d6383612bcf565b946020939093013593505050565b600060208284031215612d82578081fd5b610c1b82612be6565b600060208284031215612d9c578081fd5b8135610c1b816133ab565b600060208284031215612db8578081fd5b8151610c1b816133ab565b600060208284031215612dd4578081fd5b81516001600160401b03811115612de9578182fd5b8201601f81018413612df9578182fd5b8051612e07612ce8826131e1565b818152856020838501011115612e1b578384fd5b612e2c8260208301602086016132aa565b95945050505050565b600060208284031215612e46578081fd5b5035919050565b60008060408385031215612e5f578182fd5b50508035926020909101359150565b60008151808452612e868160208601602086016132aa565b601f01601f19169290920160200192915050565b8a151560f890811b82526001600160f81b03198b821b811660018401528a821b8116600284015289821b8116600384015288821b8116600484015287821b8116600584015286821b811660068401529085901b1660078201526000612f0e600883018560f81b6001600160f81b0319169052565b612f27600983018460f81b6001600160f81b0319169052565b50600a019a9950505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612f6c90830184612e6e565b9695505050505050565b602081526000610c1b6020830184612e6e565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526019908201527f4f6e6c792061646d696e732063616e2063616c6c207468697300000000000000604082015260600190565b602080825260119082015270686d6d6d6d207768617420646f696e673f60781b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b8151151581526101408101602083015161310c602084018260ff169052565b506040830151613121604084018260ff169052565b506060830151613136606084018260ff169052565b50608083015161314b608084018260ff169052565b5060a083015161316060a084018260ff169052565b5060c083015161317560c084018260ff169052565b5060e083015161318a60e084018260ff169052565b506101008381015160ff908116918401919091526101209384015116929091019190915290565b604051601f8201601f191681016001600160401b03811182821017156131d9576131d9613395565b604052919050565b60006001600160401b038211156131fa576131fa613395565b50601f01601f191660200190565b600061ffff80831681851680830382111561322557613225613369565b01949350505050565b6000821982111561324157613241613369565b500190565b600060ff821660ff84168060ff0382111561326357613263613369565b019392505050565b60008282101561327d5761327d613369565b500390565b60006001600160401b03838116908316818110156132a2576132a2613369565b039392505050565b60005b838110156132c55781810151838201526020016132ad565b838111156117165750506000910152565b600181811c908216806132ea57607f821691505b6020821081141561330b57634e487b7160e01b600052602260045260246000fd5b50919050565b600061ffff8083168181141561332957613329613369565b6001019392505050565b6000826133425761334261337f565b500690565b600060ff83168061335a5761335a61337f565b8060ff84160691505092915050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610a4d57600080fdfea26469706673582212206e36c968769ec773d843b52c945299db8d8ffa9786c322bc6bd9c5a942c511f564736f6c63430008040033
[ 21, 10, 5 ]
0xf3b5589684aa48ee7f559c58bc66ac74b95ca319
pragma solidity ^0.4.18; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title 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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Escrow is Ownable { using SafeMath for uint256; struct EscrowElement { bool exists; address src; address dst; uint256 value; } address public token; ERC20 public tok; mapping (bytes20 => EscrowElement) public escrows; /* Numerator and denominator of common fraction. E.g. 1 & 25 mean one twenty fifths, i.e. 0.04 = 4% */ uint256 public escrow_fee_numerator; /* 1 */ uint256 public escrow_fee_denominator; /* 25 */ event EscrowStarted( bytes20 indexed escrow_id, EscrowElement escrow_element ); event EscrowReleased( bytes20 indexed escrow_id, EscrowElement escrow_element ); event EscrowCancelled( bytes20 indexed escrow_id, EscrowElement escrow_element ); event TokenSet( address indexed token ); event Withdrawed( address indexed dst, uint256 value ); function Escrow(address _token){ token = _token; tok = ERC20(_token); escrow_fee_numerator = 1; escrow_fee_denominator = 25; } function startEscrow(bytes20 escrow_id, address to, uint256 value) public returns (bool) { require(to != address(0)); require(escrows[escrow_id].exists != true); // ERC20 tok = ERC20(token); tok.transferFrom(msg.sender, address(this), value); EscrowElement memory escrow_element = EscrowElement(true, msg.sender, to, value); escrows[escrow_id] = escrow_element; emit EscrowStarted(escrow_id, escrow_element); return true; } function releaseEscrow(bytes20 escrow_id, address fee_destination) onlyOwner returns (bool) { require(fee_destination != address(0)); require(escrows[escrow_id].exists == true); EscrowElement storage escrow_element = escrows[escrow_id]; uint256 fee = escrow_element.value.mul(escrow_fee_numerator).div(escrow_fee_denominator); uint256 value = escrow_element.value.sub(fee); // ERC20 tok = ERC20(token); tok.transfer(escrow_element.dst, value); tok.transfer(fee_destination, fee); EscrowElement memory _escrow_element = escrow_element; emit EscrowReleased(escrow_id, _escrow_element); delete escrows[escrow_id]; return true; } function cancelEscrow(bytes20 escrow_id) onlyOwner returns (bool) { EscrowElement storage escrow_element = escrows[escrow_id]; // ERC20 tok = ERC20(token); tok.transfer(escrow_element.src, escrow_element.value); /* Workaround because of lack of feature. See https://github.com/ethereum/solidity/issues/3577 */ EscrowElement memory _escrow_element = escrow_element; emit EscrowCancelled(escrow_id, _escrow_element); delete escrows[escrow_id]; return true; } function withdrawToken(address dst, uint256 value) onlyOwner returns (bool){ require(dst != address(0)); require(value > 0); // ERC20 tok = ERC20(token); tok.transfer(dst, value); emit Withdrawed(dst, value); return true; } function setToken(address _token) onlyOwner returns (bool){ require(_token != address(0)); token = _token; tok = ERC20(_token); emit TokenSet(_token); return true; } // }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063144fa6d7146100ca5780634ab74a1e146101255780636cbb9d191461017c578063715018a6146101f05780638da5cb5b146102075780639d10fda81461025e5780639dc18296146102895780639e281a981461034a5780639f6822b4146103af578063d9da01421461042d578063f2fde38b14610481578063f4ba89f9146104c4578063fc0c546a146104ef575b600080fd5b3480156100d657600080fd5b5061010b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610546565b604051808215151515815260200191505060405180910390f35b34801561013157600080fd5b5061013a6106ad565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561018857600080fd5b506101d660048036038101908080356bffffffffffffffffffffffff19169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106d3565b604051808215151515815260200191505060405180910390f35b3480156101fc57600080fd5b50610205610c40565b005b34801561021357600080fd5b5061021c610d42565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561026a57600080fd5b50610273610d67565b6040518082815260200191505060405180910390f35b34801561029557600080fd5b506102c360048036038101908080356bffffffffffffffffffffffff19169060200190929190505050610d6d565b60405180851515151581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390f35b34801561035657600080fd5b50610395600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dea565b604051808215151515815260200191505060405180910390f35b3480156103bb57600080fd5b5061041360048036038101908080356bffffffffffffffffffffffff19169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610feb565b604051808215151515815260200191505060405180910390f35b34801561043957600080fd5b5061046760048036038101908080356bffffffffffffffffffffffff1916906020019092919050505061134e565b604051808215151515815260200191505060405180910390f35b34801561048d57600080fd5b506104c2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116e0565b005b3480156104d057600080fd5b506104d9611747565b6040518082815260200191505060405180910390f35b3480156104fb57600080fd5b5061050461174d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105a357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156105df57600080fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff167fa07c91c183e42229e705a9795a1c06d76528b673788b849597364528c96eefb760405160405180910390a260019050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806106e16118d4565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561073c57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415151561077857600080fd5b6001151560036000896bffffffffffffffffffffffff19166bffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900460ff1615151415156107cc57600080fd5b60036000886bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152602001908152602001600020935061082c60055461081e600454876002015461177390919063ffffffff16565b6117ab90919063ffffffff16565b92506108458385600201546117c190919063ffffffff16565b9150600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8560010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561093057600080fd5b505af1158015610944573d6000803e3d6000fd5b505050506040513d602081101561095a57600080fd5b810190808051906020019092919050505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610a3157600080fd5b505af1158015610a45573d6000803e3d6000fd5b505050506040513d6020811015610a5b57600080fd5b81019080805190602001909291905050505083608060405190810160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820154815250509050866bffffffffffffffffffffffff19167f19fb20e5d27825ce7ee0f426679098734e175df25b05725a44bdfaaf16b40ee0826040518082815260200191505060405180910390a260036000886bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549060ff02191690556000820160016101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560028201600090555050600194505050505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c9b57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a260008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60036020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020154905084565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e4757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610e8357600080fd5b600082111515610e9257600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610f5757600080fd5b505af1158015610f6b573d6000803e3d6000fd5b505050506040513d6020811015610f8157600080fd5b8101908080519060200190929190505050508273ffffffffffffffffffffffffffffffffffffffff167f6cca423c6ffc06e62a0acc433965e074b11c28479b0449250ce3ff65ac9e39fe836040518082815260200191505060405180910390a26001905092915050565b6000610ff56118d4565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561103157600080fd5b6001151560036000876bffffffffffffffffffffffff19166bffffffffffffffffffffffff1916815260200190815260200160002060000160009054906101000a900460ff1615151415151561108657600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561117f57600080fd5b505af1158015611193573d6000803e3d6000fd5b505050506040513d60208110156111a957600080fd5b8101908080519060200190929190505050506080604051908101604052806001151581526020013373ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018481525090508060036000876bffffffffffffffffffffffff19166bffffffffffffffffffffffff1916815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060608201518160020155905050846bffffffffffffffffffffffff19167fef534b708cf0aeb9422d4c091036c932950840ccea3a1ee17c5b77e0a6706cd3826040518082815260200191505060405180910390a260019150509392505050565b6000806113596118d4565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113b457600080fd5b60036000856bffffffffffffffffffffffff19166bffffffffffffffffffffffff191681526020019081526020016000209150600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8360000160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684600201546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114d457600080fd5b505af11580156114e8573d6000803e3d6000fd5b505050506040513d60208110156114fe57600080fd5b81019080805190602001909291905050505081608060405190810160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820154815250509050836bffffffffffffffffffffffff19167fe1b2fe6a926abc7057869b0844bd256832328512c132bcadf9493b03bfa56f88826040518082815260200191505060405180910390a260036000856bffffffffffffffffffffffff19166bffffffffffffffffffffffff19168152602001908152602001600020600080820160006101000a81549060ff02191690556000820160016101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560028201600090555050600192505050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561173b57600080fd5b611744816117da565b50565b60045481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008083141561178657600090506117a5565b818302905081838281151561179757fe5b041415156117a157fe5b8090505b92915050565b600081838115156117b857fe5b04905092915050565b60008282111515156117cf57fe5b818303905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561181657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b608060405190810160405280600015158152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815250905600a165627a7a72305820a92317f888d57875ad76851b95ea1e32daf99a0b956c4bf7649b811736c085e50029
[ 16, 7 ]
0xf3b653933e32b58c173f3f9a77fc20207d61a589
pragma solidity ^0.5.15; /* :'######::'########:'########::'#######:: '##... ##: ##.....::... ##..::'##.... ##: ##:::..:: ##:::::::::: ##:::: ##:::: ##: ##::::::: ######:::::: ##:::: ##:::: ##: ##::::::: ##...::::::: ##:::: ##:::: ##: ##::: ##: ##:::::::::: ##:::: ##:::: ##: . ######:: ########:::: ##::::. #######:: :......:::........:::::..::::::.......::: Creator: 773d62b24a9d49e1f990b22e3ef1a9903f44ee809a12d73e660c66c1772c47dd */ contract Hourglass { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator() { address _customerAddress = msg.sender; require(administrators[_customerAddress], "This address is not an admin"); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum) { // are we still in the vulnerable phase? // if so, enact anti early whale protocol if (onlyAmbassadors) { address _customerAddress = msg.sender; if ( (totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ ) { require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add( ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum ); // execute _; } else { // in case the trx count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } // execute _; } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); event Approval( address indexed owner, address indexed spender, uint256 value ); // When a customer sets up AutoReinvestment event onAutoReinvestmentEntry( address indexed customerAddress, uint256 nextExecutionTime, uint256 rewardPerInvocation, uint24 period, uint256 minimumDividendValue ); // When a customer stops AutoReinvestment event onAutoReinvestmentStop(address indexed customerAddress); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "Crystal Elephant Token"; string public symbol = "ECETO"; uint8 public constant decimals = 18; uint8 internal constant dividendFee_ = 10; uint256 internal constant tokenPriceInitial_ = 100e9; // unit: wei uint256 internal constant tokenPriceIncremental_ = 10e9; // unit: wei uint256 internal constant magnitude = 2**64; // requirement for earning a referral bonus (defaults at 360 tokens) uint256 public stakingRequirement = 30e18; // ambassador program mapping(address => bool) public ambassadors_; uint256 internal constant ambassadorMaxPurchase_ = 4e18; // 4 ETH uint256 internal constant ambassadorQuota_ = 100e18; // 100 ETH /*================================ = DATASETS = ================================*/ // amount of tokens for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; // TODO: // amount of tokens bought with their buy timestamp for each address struct TimestampedBalance { uint256 value; uint256 timestamp; uint256 valueSold; } mapping(address => TimestampedBalance[]) internal tokenTimestampedBalanceLedger_; // The start and end index of the unsold timestamped transactions list struct Cursor { uint256 start; uint256 end; } mapping(address => Cursor) internal tokenTimestampedBalanceCursor; // mappings to and from referral address mapping(address => bytes32) public referralMapping; mapping(bytes32 => address) public referralReverseMapping; // The current referral balance mapping(address => uint256) public referralBalance_; // All time referrals earnings mapping(address => uint256) public referralIncome_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ constructor() public { address owner = msg.sender; administrators[owner] = true; ambassadors_[0x8c67C528a78c3142eEbA7A9FB9966c3141ABFc07] = true; ambassadors_[0xA3085Dc923e5de6E1919CFaE73a4D4557CF31734] = true; ambassadors_[0x62544c00f6458011796605E8E6E7F799E17b1348] = true; ambassadors_[0x5357777ddD555a192E1E87b96a93aAdcC463D0f8] = true; ambassadors_[0x8713c7d84dA4edC2795EbaBfFdeEF4bB2Ef654Df] = true; ambassadors_[0xC8b17a71fE39dB3AdD2438B89C1522d03767ebDA] = true; ambassadors_[0x6B6dDbb85000EFCbff006BEa12CeD803Fd0a0B96] = true; ambassadors_[0x2F09612675A16E9D97e8A0c27D2285A5d8FB6EBa] = true; ambassadors_[0xD82f5174e03E3352a35a933a11100e6c2607Ba1E] = true; ambassadors_[0x28eb45DB2c42b56A1C5BC915F4cc47DD79239632] = true; ambassadors_[0x12B2398405f49dEc00D7ceEF9C0925e6fc96c51F] = true; ambassadors_[0x32c0aE75EF5BEB409a17fcf26fDDb8561EEF8394] = true; ambassadors_[0x2FC1DbA620e749E86E51C2d9c42993174E1986ce] = true; ambassadors_[0xDBfc64ff6C4d85f42D8411680ebe90aD06bF3E81] = true; ambassadors_[0xBD54eb8AD245450e225A77Af5956F2b41301c845] = true; ambassadors_[0x58d1a5e3ca23F46E16BcA17849CE327a415A2ee5] = true; ambassadors_[0x33a2e739b428508643Ee49d874775e1196178A1c] = true; ambassadors_[0x45ADFF324Eb1ac03a6A115dc539052232D4bA980] = true; ambassadors_[0x3e666E4B6091263F3A70C004E47a1e172f31Ff42] = true; ambassadors_[0x766917c3Ee4AA5164b3A6F01363865efA8CE6fFd] = true; ambassadors_[0x3Ee362b5DB70c2935e718f7711B1CCAC7dbAd081] = true; ambassadors_[0xcb1A0F26c89fbC1BCb14fE1Ee9a2785BAE419e81] = true; } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() external payable { purchaseTokens(msg.sender, msg.value, address(0)); } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable { purchaseTokens(msg.sender, msg.value, _referredBy); } /** * Converts all of caller's dividends to tokens. */ function reinvest( bool isAutoReinvestChecked, uint24 period, uint256 rewardPerInvocation, uint256 minimumDividendValue ) public { _reinvest(msg.sender); // Setup Auto Reinvestment if (isAutoReinvestChecked) { _setupAutoReinvest( period, rewardPerInvocation, msg.sender, minimumDividendValue ); } } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() public { _withdraw(msg.sender); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) public onlyBagholders() { // setup data address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 penalty = mulDiv( calculateAveragePenaltyAndUpdateLedger( _amountOfTokens, _customerAddress ), _ethereum, 100 ); uint256 _dividends = SafeMath.add( penalty, SafeMath.div(SafeMath.sub(_ethereum, penalty), dividendFee_) ); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub( tokenBalanceLedger_[_customerAddress], _tokens ); // update dividends tracker int256 _updatedPayouts = (int256)(profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add( profitPerShare_, mulDiv(_dividends, magnitude, tokenSupply_) ); } emit onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() public onlyAdministrator() { onlyAmbassadors = false; } function setAdministrator(address _identifier, bool _status) public onlyAdministrator() { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) public onlyAdministrator() { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string memory _name) public onlyAdministrator() { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string memory _symbol) public onlyAdministrator() { symbol = _symbol; } /*---------- REFERRAL FUNCTIONS ----------*/ function setReferralName(bytes32 ref_name) public returns (bool) { referralMapping[msg.sender] = ref_name; referralReverseMapping[ref_name] = msg.sender; return true; } function getReferralAddressForName(bytes32 ref_name) public view returns (address) { return referralReverseMapping[ref_name]; } function getReferralNameForAddress(address ref_address) public view returns (bytes32) { return referralMapping[ref_address]; } function getReferralBalance() public view returns (uint256, uint256) { address _customerAddress = msg.sender; return ( referralBalance_[_customerAddress], referralIncome_[_customerAddress] ); } /*------READ FUNCTIONS FOR TIMESTAMPED BALANCE LEDGER-------*/ function getCursor() public view returns (uint256, uint256) { address _customerAddress = msg.sender; Cursor storage cursor = tokenTimestampedBalanceCursor[_customerAddress]; return (cursor.start, cursor.end); } function getTimestampedBalanceLedger(uint256 counter) public view returns ( uint256, uint256, uint256 ) { address _customerAddress = msg.sender; TimestampedBalance storage transaction = tokenTimestampedBalanceLedger_[_customerAddress][counter]; return ( transaction.value, transaction.timestamp, transaction.valueSold ); } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns (uint256) { return address(this).balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns (uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns (uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns (uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress); } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) public view returns (uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) public view returns (uint256) { return (uint256)( (int256)( profitPerShare_ * tokenBalanceLedger_[_customerAddress] ) - payoutsTo_[_customerAddress] ) / magnitude; } /** * Return the ethereum received on selling 1 individual token. * We are not deducting the penalty over here as it's a general sell price * the user can use the `calculateEthereumReceived` to get the sell price specific to them */ function sellPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /** * Return the ethereum required for buying 1 individual token. */ function buyPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _taxedEthereum = mulDiv(_ethereum, dividendFee_, (dividendFee_ - 1)); return _taxedEthereum; } } /* * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateTokensReinvested() public view returns (uint256) { uint256 _ethereumToSpend = myDividends(true); uint256 _dividends = SafeMath.div(_ethereumToSpend, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); require(_tokensToSell <= myTokens()); uint256 _ethereum = tokensToEthereum_(_tokensToSell); address _customerAddress = msg.sender; uint256 penalty = mulDiv( calculateAveragePenalty(_tokensToSell, _customerAddress), _ethereum, 100 ); uint256 _dividends = SafeMath.add( penalty, SafeMath.div(SafeMath.sub(_ethereum, penalty), dividendFee_) ); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } function calculateEthereumTransferred(uint256 _amountOfTokens) public view returns (uint256) { require(_amountOfTokens <= tokenSupply_); require(_amountOfTokens <= myTokens()); uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); return _taxedTokens; } /** * Calculate the early exit penalty for selling x tokens */ function calculateAveragePenalty( uint256 _amountOfTokens, address _customerAddress ) public view onlyBagholders() returns (uint256) { require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 tokensFound = 0; Cursor storage _customerCursor = tokenTimestampedBalanceCursor[_customerAddress]; uint256 counter = _customerCursor.start; uint256 averagePenalty = 0; while (counter <= _customerCursor.end) { TimestampedBalance storage transaction = tokenTimestampedBalanceLedger_[_customerAddress][counter]; uint256 tokensAvailable = SafeMath.sub(transaction.value, transaction.valueSold); uint256 tokensRequired = SafeMath.sub(_amountOfTokens, tokensFound); if (tokensAvailable < tokensRequired) { tokensFound += tokensAvailable; averagePenalty = SafeMath.add( averagePenalty, SafeMath.mul( _calculatePenalty(transaction.timestamp), tokensAvailable ) ); } else if (tokensAvailable <= tokensRequired) { averagePenalty = SafeMath.add( averagePenalty, SafeMath.mul( _calculatePenalty(transaction.timestamp), tokensRequired ) ); break; } else { averagePenalty = SafeMath.add( averagePenalty, SafeMath.mul( _calculatePenalty(transaction.timestamp), tokensRequired ) ); break; } counter = SafeMath.add(counter, 1); } return SafeMath.div(averagePenalty, _amountOfTokens); } /** * Calculate the early exit penalty for selling after x days */ function _calculatePenalty(uint256 timestamp) public view returns (uint256) { uint256 gap = block.timestamp - timestamp; if (gap > 30 days) { return 0; } else if (gap > 20 days) { return 25; } else if (gap > 10 days) { return 50; } return 75; } /** * Calculate Token price based on an amount of incoming ethereum * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) public view returns (uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = (( SafeMath.sub( ( sqrt( (_tokenPriceInitial**2) + (2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18)) + (((tokenPriceIncremental_)**2) * (tokenSupply_**2)) + (2 * (tokenPriceIncremental_) * _tokenPriceInitial * tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_)) - (tokenSupply_); return _tokensReceived; } /** * Calculate token sell value. * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) public view returns (uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _ethereumReceived = (SafeMath.sub( (((tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18))) - tokenPriceIncremental_) * (tokens_ - 1e18)), (tokenPriceIncremental_ * ((tokens_**2 - tokens_) / 1e18)) / 2 ) / 1e18); return _ethereumReceived; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens( address _customerAddress, uint256 _incomingEthereum, address _referredBy ) internal antiEarlyWhale(_incomingEthereum) returns (uint256) { // data setup uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; require( _amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_ ); // is the user referred by a masternode? if ( _referredBy != address(0) && _referredBy != _customerAddress && tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { // wealth redistribution referralBalance_[_referredBy] = SafeMath.add( referralBalance_[_referredBy], _referralBonus ); referralIncome_[_referredBy] = SafeMath.add( referralIncome_[_referredBy], _referralBonus ); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } if (tokenSupply_ > 0) { // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += ((_dividends * magnitude) / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee - (_amountOfTokens * ((_dividends * magnitude) / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add( tokenBalanceLedger_[_customerAddress], _amountOfTokens ); tokenTimestampedBalanceLedger_[_customerAddress].push( TimestampedBalance(_amountOfTokens, block.timestamp, 0) ); tokenTimestampedBalanceCursor[_customerAddress].end += 1; // You don't get dividends for the tokens before they owned them int256 _updatedPayouts = (int256)(profitPerShare_ * _amountOfTokens - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event emit onTokenPurchase( _customerAddress, _incomingEthereum, _amountOfTokens, _referredBy ); emit Transfer( address(0), _customerAddress, _amountOfTokens ); return _amountOfTokens; } function _reinvest(address _customerAddress) internal { uint256 _dividends = dividendsOf(_customerAddress); // onlyStronghands require(_dividends + referralBalance_[_customerAddress] > 0); payoutsTo_[_customerAddress] += (int256)(_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_customerAddress, _dividends, address(0)); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } function _withdraw(address _customerAddress) internal { uint256 _dividends = dividendsOf(_customerAddress); // get ref. bonus later in the code // onlyStronghands require(_dividends + referralBalance_[_customerAddress] > 0); // update dividend tracker payoutsTo_[_customerAddress] += (int256)(_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; address payable _payableCustomerAddress = address(uint160(_customerAddress)); _payableCustomerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /** * Update ledger after transferring x tokens */ function _updateLedgerForTransfer( uint256 _amountOfTokens, address _customerAddress ) internal { // Parse through the list of transactions uint256 tokensFound = 0; Cursor storage _customerCursor = tokenTimestampedBalanceCursor[_customerAddress]; uint256 counter = _customerCursor.start; while (counter <= _customerCursor.end) { TimestampedBalance storage transaction = tokenTimestampedBalanceLedger_[_customerAddress][counter]; uint256 tokensAvailable = SafeMath.sub(transaction.value, transaction.valueSold); uint256 tokensRequired = SafeMath.sub(_amountOfTokens, tokensFound); if (tokensAvailable < tokensRequired) { tokensFound += tokensAvailable; delete tokenTimestampedBalanceLedger_[_customerAddress][ counter ]; } else if (tokensAvailable <= tokensRequired) { delete tokenTimestampedBalanceLedger_[_customerAddress][ counter ]; _customerCursor.start = counter + 1; break; } else { transaction.valueSold += tokensRequired; _customerCursor.start = counter; break; } counter += 1; } } /** * Calculate the early exit penalty for selling x tokens and edit the timestamped ledger */ function calculateAveragePenaltyAndUpdateLedger( uint256 _amountOfTokens, address _customerAddress ) internal onlyBagholders() returns (uint256) { // Parse through the list of transactions uint256 tokensFound = 0; Cursor storage _customerCursor = tokenTimestampedBalanceCursor[_customerAddress]; uint256 counter = _customerCursor.start; uint256 averagePenalty = 0; while (counter <= _customerCursor.end) { TimestampedBalance storage transaction = tokenTimestampedBalanceLedger_[_customerAddress][counter]; uint256 tokensAvailable = SafeMath.sub(transaction.value, transaction.valueSold); uint256 tokensRequired = SafeMath.sub(_amountOfTokens, tokensFound); if (tokensAvailable < tokensRequired) { tokensFound += tokensAvailable; averagePenalty = SafeMath.add( averagePenalty, SafeMath.mul( _calculatePenalty(transaction.timestamp), tokensAvailable ) ); delete tokenTimestampedBalanceLedger_[_customerAddress][ counter ]; } else if (tokensAvailable <= tokensRequired) { averagePenalty = SafeMath.add( averagePenalty, SafeMath.mul( _calculatePenalty(transaction.timestamp), tokensRequired ) ); delete tokenTimestampedBalanceLedger_[_customerAddress][ counter ]; _customerCursor.start = counter + 1; break; } else { averagePenalty = SafeMath.add( averagePenalty, SafeMath.mul( _calculatePenalty(transaction.timestamp), tokensRequired ) ); transaction.valueSold += tokensRequired; _customerCursor.start = counter; break; } counter += 1; } return SafeMath.div(averagePenalty, _amountOfTokens); } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } /** * @dev calculates x*y and outputs a emulated 512bit number as l being the lower 256bit half and h the upper 256bit half. */ function fullMul(uint256 x, uint256 y) public pure returns (uint256 l, uint256 h) { uint256 mm = mulmod(x, y, uint256(-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } /** * @dev calculates x*y/z taking care of phantom overflows. */ function mulDiv( uint256 x, uint256 y, uint256 z ) public pure returns (uint256) { (uint256 l, uint256 h) = fullMul(x, y); require(h < z); uint256 mm = mulmod(x, y, z); if (mm > l) h -= 1; l -= mm; uint256 pow2 = z & -z; z /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint256 r = 1; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; return l * r; } /* * ========================= * Auto Reinvestment Feature * ========================= */ // uint256 recommendedRewardPerInvocation = 5000000; // 5 TRX struct AutoReinvestEntry { uint256 nextExecutionTime; uint256 rewardPerInvocation; uint256 minimumDividendValue; uint24 period; } mapping(address => AutoReinvestEntry) internal autoReinvestment; function setupAutoReinvest( uint24 period, uint256 rewardPerInvocation, uint256 minimumDividendValue ) public { _setupAutoReinvest( period, rewardPerInvocation, msg.sender, minimumDividendValue ); } function _setupAutoReinvest( uint24 period, uint256 rewardPerInvocation, address customerAddress, uint256 minimumDividendValue ) internal { autoReinvestment[customerAddress] = AutoReinvestEntry( block.timestamp + period, rewardPerInvocation, minimumDividendValue, period ); // Launch an event that this entry has been created emit onAutoReinvestmentEntry( customerAddress, autoReinvestment[customerAddress].nextExecutionTime, rewardPerInvocation, period, minimumDividendValue ); } // Anyone can call this function and claim the reward function invokeAutoReinvest(address _customerAddress) external returns (uint256) { AutoReinvestEntry storage entry = autoReinvestment[_customerAddress]; if ( entry.nextExecutionTime > 0 && block.timestamp >= entry.nextExecutionTime ) { // fetch dividends uint256 _dividends = dividendsOf(_customerAddress); // Only execute if the user's dividends are more that the // rewardPerInvocation and the minimumDividendValue if ( _dividends > entry.minimumDividendValue && _dividends > entry.rewardPerInvocation ) { // Deduct the reward from the users dividends payoutsTo_[_customerAddress] += (int256)( entry.rewardPerInvocation * magnitude ); // Update the Auto Reinvestment entry entry.nextExecutionTime += (((block.timestamp - entry.nextExecutionTime) / uint256(entry.period)) + 1) * uint256(entry.period); /* * Do the reinvestment */ _reinvest(_customerAddress); // Send the caller their reward msg.sender.transfer(entry.rewardPerInvocation); } } return entry.nextExecutionTime; } // Read function for the frontend to determine if the user has setup Auto Reinvestment or not function getAutoReinvestEntry() public view returns ( uint256, uint256, uint24, uint256 ) { address _customerAddress = msg.sender; AutoReinvestEntry storage _autoReinvestEntry = autoReinvestment[_customerAddress]; return ( _autoReinvestEntry.nextExecutionTime, _autoReinvestEntry.rewardPerInvocation, _autoReinvestEntry.period, _autoReinvestEntry.minimumDividendValue ); } // Read function for the scheduling workers determine if the user has setup Auto Reinvestment or not function getAutoReinvestEntryOf(address _customerAddress) public view returns ( uint256, uint256, uint24, uint256 ) { AutoReinvestEntry storage _autoReinvestEntry = autoReinvestment[_customerAddress]; return ( _autoReinvestEntry.nextExecutionTime, _autoReinvestEntry.rewardPerInvocation, _autoReinvestEntry.period, _autoReinvestEntry.minimumDividendValue ); } // The user can stop the autoReinvestment whenever they want function stopAutoReinvest() external { address customerAddress = msg.sender; if (autoReinvestment[customerAddress].nextExecutionTime > 0) { delete autoReinvestment[customerAddress]; // Launch an event that this entry has been deleted emit onAutoReinvestmentStop(customerAddress); } } // Allowance, Approval and Transfer From mapping(address => mapping(address => uint256)) private _allowances; function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public returns (bool) { uint256 final_amount = SafeMath.sub(_allowances[sender][msg.sender], amount); _transfer(sender, recipient, amount); _approve(sender, msg.sender, final_amount); return true; } function transfer(address _toAddress, uint256 _amountOfTokens) public onlyBagholders returns (bool) { _transfer(msg.sender, _toAddress, _amountOfTokens); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient` after liquifying 10% of the tokens `amount` as dividens. * * 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: * * - `_customerAddress` cannot be the zero address. * - `_toAddress` cannot be the zero address. * - `_customerAddress` must have a balance of at least `_amountOfTokens`. */ function _transfer( address _customerAddress, address _toAddress, uint256 _amountOfTokens ) internal { require( _customerAddress != address(0), "ERC20: transfer from the zero address" ); require( _toAddress != address(0), "ERC20: transfer to the zero address" ); // also disables transfers until ambassador phase is over // ( we dont want whale premines ) // make sure we have the requested tokens require( !onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress] ); // withdraw all outstanding dividends first if ( dividendsOf(_customerAddress) + referralBalance_[_customerAddress] > 0 ) { _withdraw(_customerAddress); } // updating tokenTimestampedBalanceLedger_ for _customerAddress _updateLedgerForTransfer(_amountOfTokens, _customerAddress); // liquify 10% of the remaining tokens that are transfered // these are dispersed to shareholders uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); // burn the fee tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub( tokenBalanceLedger_[_customerAddress], _amountOfTokens ); tokenBalanceLedger_[_toAddress] = SafeMath.add( tokenBalanceLedger_[_toAddress], _taxedTokens ); // updating tokenTimestampedBalanceLedger_ for _toAddress tokenTimestampedBalanceLedger_[_toAddress].push( TimestampedBalance(_taxedTokens, block.timestamp, 0) ); tokenTimestampedBalanceCursor[_toAddress].end += 1; // update dividend trackers payoutsTo_[_customerAddress] -= (int256)( profitPerShare_ * _amountOfTokens ); payoutsTo_[_toAddress] += (int256)(profitPerShare_ * _taxedTokens); // disperse dividends among holders profitPerShare_ = SafeMath.add( profitPerShare_, mulDiv(_dividends, magnitude, tokenSupply_) ); // fire event emit Transfer(_customerAddress, _toAddress, _taxedTokens); } // Atomically increases the allowance granted to `spender` by the caller. function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { uint256 final_allowance = SafeMath.add(_allowances[msg.sender][spender], addedValue); _approve(msg.sender, spender, final_allowance); return true; } //Atomically decreases the allowance granted to `spender` by the caller. function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { uint256 final_allowance = SafeMath.sub(_allowances[msg.sender][spender], subtractedValue); _approve(msg.sender, spender, final_allowance); return true; } // Sets `amount` as the allowance of `spender` over the `owner`s tokens. function _approve( address owner, address spender, uint256 value ) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value); } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
0x60806040526004361061036a5760003560e01c80636b2f4632116101c6578063a8e04f34116100f7578063c664f7f111610095578063e9fad8ee1161006f578063e9fad8ee14611586578063ec536a171461159d578063ee7743ca146115e7578063f088d547146116475761036a565b8063c664f7f114611461578063dd62ed3e146114c6578063e4849b321461154b5761036a565b8063b84c8246116100d1578063b84c82461461126b578063bbcb15cc14611333578063bf3b397b1461134a578063c47f0027146113995761036a565b8063a8e04f341461117e578063a9059cbb14611195578063aa9a0912146112085761036a565b80638620410b11610164578063949e8acd1161013e578063949e8acd14610fcc57806395d89b4114610ff7578063a457c2d714611087578063a7c73c3e146110fa5761036a565b80638620410b14610edf57806387c9505814610f0a5780638d12530f14610f675761036a565b806370a08231116101a057806370a0823114610d8757806376be158514610dec5780637ad20cac14610e555780638328b61014610ea45761036a565b80636b2f463214610c925780636d93805814610cbd5780636dc7bed014610d225761036a565b8063380169ea116102a0578063542f76a51161023e5780636122d906116102185780636122d90614610b1357806367a4a3dd14610b7c578063688abbf714610bdc5780636988a3ef14610c2d5761036a565b8063542f76a514610a3c57806356d399e814610a8b5780635db6d1d214610ab65761036a565b80634193d03a1161027a5780634193d03a146108f5578063452cf42d146109645780634b750334146109df5780634c33047114610a0a5761036a565b8063380169ea14610839578063395093511461086b5780633ccfd60b146108de5761036a565b8063229f465d1161030d57806327defa1f116102e757806327defa1f1461070f5780632a2d2b971461073e5780632a9121c7146107b9578063313ce567146108085761036a565b8063229f465d146105d557806323b872dd1461062957806323d114be146106bc5761036a565b80630ad0385a116103495780630ad0385a146104e157806310d0ffdd1461050c57806318160ddd1461055b57806322609373146105865761036a565b806265318b1461037957806306fdde03146103de578063095ea7b31461046e575b6103763334600061168b565b50005b34801561038557600080fd5b506103c86004803603602081101561039c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506128f8565b6040518082815260200191505060405180910390f35b3480156103ea57600080fd5b506103f3612998565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610433578082015181840152602081019050610418565b50505050905090810190601f1680156104605780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047a57600080fd5b506104c76004803603604081101561049157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612a36565b604051808215151515815260200191505060405180910390f35b3480156104ed57600080fd5b506104f6612a4d565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b506105456004803603602081101561052f57600080fd5b8101908080359060200190929190505050612a93565b6040518082815260200191505060405180910390f35b34801561056757600080fd5b50610570612acc565b6040518082815260200191505060405180910390f35b34801561059257600080fd5b506105bf600480360360208110156105a957600080fd5b8101908080359060200190929190505050612ad6565b6040518082815260200191505060405180910390f35b3480156105e157600080fd5b50610627600480360360608110156105f857600080fd5b81019080803562ffffff1690602001909291908035906020019092919080359060200190929190505050612b65565b005b34801561063557600080fd5b506106a26004803603606081101561064c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612b76565b604051808215151515815260200191505060405180910390f35b3480156106c857600080fd5b506106f5600480360360208110156106df57600080fd5b8101908080359060200190929190505050612c23565b604051808215151515815260200191505060405180910390f35b34801561071b57600080fd5b50610724612cc4565b604051808215151515815260200191505060405180910390f35b34801561074a57600080fd5b506107776004803603602081101561076157600080fd5b8101908080359060200190929190505050612cd7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107c557600080fd5b506107f2600480360360208110156107dc57600080fd5b8101908080359060200190929190505050612d14565b6040518082815260200191505060405180910390f35b34801561081457600080fd5b5061081d612d9f565b604051808260ff1660ff16815260200191505060405180910390f35b34801561084557600080fd5b5061084e612da4565b604051808381526020018281526020019250505060405180910390f35b34801561087757600080fd5b506108c46004803603604081101561088e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612e03565b604051808215151515815260200191505060405180910390f35b3480156108ea57600080fd5b506108f3612ea4565b005b34801561090157600080fd5b5061094e6004803603604081101561091857600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612eaf565b6040518082815260200191505060405180910390f35b34801561097057600080fd5b5061099d6004803603602081101561098757600080fd5b81019080803590602001909291905050506130a9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156109eb57600080fd5b506109f46130dc565b6040518082815260200191505060405180910390f35b348015610a1657600080fd5b50610a1f61313b565b604051808381526020018281526020019250505060405180910390f35b348015610a4857600080fd5b50610a7560048036036020811015610a5f57600080fd5b81019080803590602001909291905050506131cc565b6040518082815260200191505060405180910390f35b348015610a9757600080fd5b50610aa061321b565b6040518082815260200191505060405180910390f35b348015610ac257600080fd5b50610aef60048036036020811015610ad957600080fd5b8101908080359060200190929190505050613221565b60405180848152602001838152602001828152602001935050505060405180910390f35b348015610b1f57600080fd5b50610b6260048036036020811015610b3657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506132a4565b604051808215151515815260200191505060405180910390f35b348015610b8857600080fd5b50610bbf60048036036040811015610b9f57600080fd5b8101908080359060200190929190803590602001909291905050506132c4565b604051808381526020018281526020019250505060405180910390f35b348015610be857600080fd5b50610c1760048036036020811015610bff57600080fd5b81019080803515159060200190929190505050613317565b6040518082815260200191505060405180910390f35b348015610c3957600080fd5b50610c7c60048036036020811015610c5057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613383565b6040518082815260200191505060405180910390f35b348015610c9e57600080fd5b50610ca761339b565b6040518082815260200191505060405180910390f35b348015610cc957600080fd5b50610d0c60048036036020811015610ce057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506133a3565b6040518082815260200191505060405180910390f35b348015610d2e57600080fd5b50610d7160048036036020811015610d4557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506133bb565b6040518082815260200191505060405180910390f35b348015610d9357600080fd5b50610dd660048036036020811015610daa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613404565b6040518082815260200191505060405180910390f35b348015610df857600080fd5b50610e3b60048036036020811015610e0f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061344d565b604051808215151515815260200191505060405180910390f35b348015610e6157600080fd5b50610e8e60048036036020811015610e7857600080fd5b810190808035906020019092919050505061346d565b6040518082815260200191505060405180910390f35b348015610eb057600080fd5b50610edd60048036036020811015610ec757600080fd5b81019080803590602001909291905050506134bf565b005b348015610eeb57600080fd5b50610ef461358e565b6040518082815260200191505060405180910390f35b348015610f1657600080fd5b50610f6560048036036040811015610f2d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506135e6565b005b348015610f7357600080fd5b50610fb660048036036020811015610f8a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613706565b6040518082815260200191505060405180910390f35b348015610fd857600080fd5b50610fe16138a5565b6040518082815260200191505060405180910390f35b34801561100357600080fd5b5061100c6138ba565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561104c578082015181840152602081019050611031565b50505050905090810190601f1680156110795780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561109357600080fd5b506110e0600480360360408110156110aa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050613958565b604051808215151515815260200191505060405180910390f35b34801561110657600080fd5b506111496004803603602081101561111d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506139f9565b604051808581526020018481526020018362ffffff1662ffffff16815260200182815260200194505050505060405180910390f35b34801561118a57600080fd5b50611193613a75565b005b3480156111a157600080fd5b506111ee600480360360408110156111b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050613b57565b604051808215151515815260200191505060405180910390f35b34801561121457600080fd5b506112556004803603606081101561122b57600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050613b81565b6040518082815260200191505060405180910390f35b34801561127757600080fd5b506113316004803603602081101561128e57600080fd5b81019080803590602001906401000000008111156112ab57600080fd5b8201836020820111156112bd57600080fd5b803590602001918460018302840111640100000000831117156112df57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613c62565b005b34801561133f57600080fd5b50611348613d41565b005b34801561135657600080fd5b506113836004803603602081101561136d57600080fd5b8101908080359060200190929190505050613e48565b6040518082815260200191505060405180910390f35b3480156113a557600080fd5b5061145f600480360360208110156113bc57600080fd5b81019080803590602001906401000000008111156113d957600080fd5b8201836020820111156113eb57600080fd5b8035906020019184600183028401116401000000008311171561140d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050613eec565b005b34801561146d57600080fd5b506114b06004803603602081101561148457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613fcb565b6040518082815260200191505060405180910390f35b3480156114d257600080fd5b50611535600480360360408110156114e957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613fe3565b6040518082815260200191505060405180910390f35b34801561155757600080fd5b506115846004803603602081101561156e57600080fd5b810190808035906020019092919050505061406a565b005b34801561159257600080fd5b5061159b6142c0565b005b3480156115a957600080fd5b506115b2614328565b604051808581526020018481526020018362ffffff1662ffffff16815260200182815260200194505050505060405180910390f35b3480156115f357600080fd5b506116456004803603608081101561160a57600080fd5b81019080803515159060200190929190803562ffffff16906020019092919080359060200190929190803590602001909291905050506143a9565b005b6116896004803603602081101561165d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506143cb565b005b600082601060009054906101000a900460ff161561235657600033905068056bc75e2d63100000826116bb61339b565b0311611d9e5760011515600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514801561176a5750673782dace9d90000082600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540111155b61177357600080fd5b6117bc600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836143da565b600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600061180f86600a60ff166143f6565b9050600061181e8260036143f6565b9050600061182c838361440f565b9050600061183a898561440f565b9050600061184782612d14565b9050600068010000000000000000840290506000821180156118755750600d5461187383600d546143da565b115b61187e57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff16141580156118e757508b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1614155b80156119345750600254600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15611a5657611982600960008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866143da565b600960008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a0e600a60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866143da565b600a60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a71565b611a6084866143da565b935068010000000000000000840290505b6000600d541115611ad857611a88600d54836143da565b600d81905550600d5468010000000000000000850281611aa457fe5b04600e60008282540192505081905550600d5468010000000000000000850281611aca57fe5b048202810381039050611ae0565b81600d819055505b611b29600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836143da565b600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180606001604052808481526020014281526020016000815250908060018154018082558091505090600182039060005260206000209060030201600090919290919091506000820151816000015560208201518160010155604082015181600201555050506001600660008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000828254019250508190555060008183600e540203905080600b60008f73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508a73ffffffffffffffffffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58e86604051808381526020018281526020019250505060405180910390a38c73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a382995050505050505050612354565b6000601060006101000a81548160ff0219169083151502179055506000611dc986600a60ff166143f6565b90506000611dd88260036143f6565b90506000611de6838361440f565b90506000611df4898561440f565b90506000611e0182612d14565b905060006801000000000000000084029050600082118015611e2f5750600d54611e2d83600d546143da565b115b611e3857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1614158015611ea157508b73ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1614155b8015611eee5750600254600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b1561201057611f3c600960008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866143da565b600960008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611fc8600a60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866143da565b600a60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061202b565b61201a84866143da565b935068010000000000000000840290505b6000600d54111561209257612042600d54836143da565b600d81905550600d546801000000000000000085028161205e57fe5b04600e60008282540192505081905550600d546801000000000000000085028161208457fe5b04820281038103905061209a565b81600d819055505b6120e3600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836143da565b600460008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180606001604052808481526020014281526020016000815250908060018154018082558091505090600182039060005260206000209060030201600090919290919091506000820151816000015560208201518160010155604082015181600201555050506001600660008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000828254019250508190555060008183600e540203905080600b60008f73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508a73ffffffffffffffffffffffffffffffffffffffff168d73ffffffffffffffffffffffffffffffffffffffff167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58e86604051808381526020018281526020019250505060405180910390a38c73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3829950505050505050505b505b600061236685600a60ff166143f6565b905060006123758260036143f6565b90506000612383838361440f565b90506000612391888561440f565b9050600061239e82612d14565b9050600068010000000000000000840290506000821180156123cc5750600d546123ca83600d546143da565b115b6123d557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff161415801561243e57508a73ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b801561248b5750600254600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b156125ad576124d9600960008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866143da565b600960008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612565600a60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054866143da565b600a60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125c8565b6125b784866143da565b935068010000000000000000840290505b6000600d54111561262f576125df600d54836143da565b600d81905550600d54680100000000000000008502816125fb57fe5b04600e60008282540192505081905550600d546801000000000000000085028161262157fe5b048202810381039050612637565b81600d819055505b612680600460008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836143da565b600460008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180606001604052808481526020014281526020016000815250908060018154018082558091505090600182039060005260206000209060030201600090919290919091506000820151816000015560208201518160010155604082015181600201555050506001600660008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000828254019250508190555060008183600e540203905080600b60008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508973ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58d86604051808381526020018281526020019250505060405180910390a38b73ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a382985050505050505050509392505050565b600068010000000000000000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600e5402038161299057fe5b049050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015612a2e5780601f10612a0357610100808354040283529160200191612a2e565b820191906000526020600020905b815481529060010190602001808311612a1157829003601f168201915b505050505081565b6000612a43338484614426565b6001905092915050565b600080612a5a6001613317565b90506000612a6c82600a60ff166143f6565b90506000612a7a838361440f565b90506000612a8782612d14565b90508094505050505090565b600080612aa483600a60ff166143f6565b90506000612ab2848361440f565b90506000612abf82612d14565b9050809350505050919050565b6000600d54905090565b6000600d54821115612ae757600080fd5b612aef6138a5565b821115612afb57600080fd5b6000612b0683613e48565b905060003390506000612b24612b1c8684612eaf565b846064613b81565b90506000612b4882612b43612b39878661440f565b600a60ff166143f6565b6143da565b90506000612b56858361440f565b90508095505050505050919050565b612b718383338461461d565b505050565b600080612bff601260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461440f565b9050612c0c858585614787565b612c17853383614426565b60019150509392505050565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550336008600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b601060009054906101000a900460ff1681565b60006008600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600080670de0b6b3a764000064174876e8000290506000600d546402540be400612d8a612d84600d54866402540be40060020202026002600d540a60026402540be4000a02670de0b6b3a76400008a02670de0b6b3a76400006402540be40002600202026002890a010101614ce3565b8561440f565b81612d9157fe5b040390508092505050919050565b601281565b60008060003390506000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050806000015481600101549350935050509091565b600080612e8c601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054846143da565b9050612e99338583614426565b600191505092915050565b612ead33614d28565b565b600080612eba6138a5565b11612ec457600080fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115612f1057600080fd5b60008090506000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000154905060008090505b82600101548211613093576000600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208381548110612fbe57fe5b906000526020600020906003020190506000612fe28260000154836002015461440f565b90506000612ff08a8861440f565b90508082101561302557818701965061301e84613019613013866001015461346d565b85614f03565b6143da565b935061307e565b8082116130555761304b84613046613040866001015461346d565b84614f03565b6143da565b9350505050613093565b6130748461306f613069866001015461346d565b84614f03565b6143da565b9350505050613093565b6130898560016143da565b9450505050612f67565b61309d81886143f6565b94505050505092915050565b60086020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080600d5414156130fc576402540be40064174876e800039050613138565b600061310f670de0b6b3a7640000613e48565b9050600061312182600a60ff166143f6565b9050600061312f838361440f565b90508093505050505b90565b6000806000339050600960008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205492509250509091565b6000600d548211156131dd57600080fd5b6131e56138a5565b8211156131f157600080fd5b600061320183600a60ff166143f6565b9050600061320f848361440f565b90508092505050919050565b60025481565b6000806000803390506000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020868154811061327657fe5b9060005260206000209060030201905080600001548160010154826002015494509450945050509193909250565b60036020528060005260406000206000915054906101000a900460ff1681565b60008060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff806132f157fe5b8486099050838502925082810391508281101561330f576001820391505b509250929050565b600080339050826133305761332b816128f8565b61337b565b600960008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613379826128f8565b015b915050919050565b60076020528060005260406000206000915090505481565b600047905090565b600a6020528060005260406000206000915090505481565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600f6020528060005260406000206000915054906101000a900460ff1681565b600080824203905062278d0081111561348a5760009150506134ba565b621a5e0081111561349f5760199150506134ba565b620d2f008111156134b45760329150506134ba565b604b9150505b919050565b6000339050600f60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16613583576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f546869732061646472657373206973206e6f7420616e2061646d696e0000000081525060200191505060405180910390fd5b816002819055505050565b600080600d5414156135ae576402540be40064174876e8000190506135e3565b60006135c1670de0b6b3a7640000613e48565b905060006135db82600a60ff166001600a0360ff16613b81565b905080925050505b90565b6000339050600f60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166136aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f546869732061646472657373206973206e6f7420616e2061646d696e0000000081525060200191505060405180910390fd5b81600f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550505050565b600080601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000154118015613762575080600001544210155b15613898576000613772846128f8565b905081600201548111801561378a5750816001015481115b156138965768010000000000000000826001015402600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508160030160009054906101000a900462ffffff1662ffffff1660018360030160009054906101000a900462ffffff1662ffffff16846000015442038161382d57fe5b040102826000016000828254019250508190555061384a84614f3a565b3373ffffffffffffffffffffffffffffffffffffffff166108fc83600101549081150290604051600060405180830381858888f19350505050158015613894573d6000803e3d6000fd5b505b505b8060000154915050919050565b6000803390506138b481613404565b91505090565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156139505780601f1061392557610100808354040283529160200191613950565b820191906000526020600020905b81548152906001019060200180831161393357829003601f168201915b505050505081565b6000806139e1601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548461440f565b90506139ee338583614426565b600191505092915050565b6000806000806000601160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050806000015481600101548260030160009054906101000a900462ffffff1683600201549450945094509450509193509193565b6000339050600f60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16613b39576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f546869732061646472657373206973206e6f7420616e2061646d696e0000000081525060200191505060405180910390fd5b6000601060006101000a81548160ff02191690831515021790555050565b600080613b626138a5565b11613b6c57600080fd5b613b77338484614787565b6001905092915050565b6000806000613b9086866132c4565b91509150838110613ba057600080fd5b60008480613baa57fe5b868809905082811115613bbe576001820391505b808303925060008560000386169050808681613bd657fe5b049550808481613be257fe5b0493506001818260000381613bf357fe5b04018302840193506000600190508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050509392505050565b6000339050600f60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16613d26576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f546869732061646472657373206973206e6f7420616e2061646d696e0000000081525060200191505060405180910390fd5b8160019080519060200190613d3c9291906155bd565b505050565b60003390506000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001541115613e4557601160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080820160009055600182016000905560028201600090556003820160006101000a81549062ffffff021916905550508073ffffffffffffffffffffffffffffffffffffffff167f6214dbd07605045f34f5c5c9a7e8cb3a40ed431c434bf262b1d0a9b485abaebe60405160405180910390a25b50565b600080670de0b6b3a7640000830190506000670de0b6b3a7640000600d540190506000670de0b6b3a7640000613ed7670de0b6b3a764000085036402540be400670de0b6b3a76400008681613e9957fe5b046402540be4000264174876e8000103026002670de0b6b3a7640000876002890a0381613ec257fe5b046402540be4000281613ed157fe5b0461440f565b81613ede57fe5b049050809350505050919050565b6000339050600f60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16613fb0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f546869732061646472657373206973206e6f7420616e2061646d696e0000000081525060200191505060405180910390fd5b8160009080519060200190613fc69291906155bd565b505050565b60096020528060005260406000206000915090505481565b6000601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60006140746138a5565b1161407e57600080fd5b6000339050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156140cf57600080fd5b600082905060006140df82613e48565b905060006140f86140f086866150e1565b836064613b81565b9050600061411c8261411761410d868661440f565b600a60ff166143f6565b6143da565b9050600061412a848361440f565b9050614138600d548661440f565b600d81905550614187600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548661440f565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600068010000000000000000820286600e540201905080600b60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506000600d54111561426057614259600e546142548568010000000000000000600d54613b81565b6143da565b600e819055505b8673ffffffffffffffffffffffffffffffffffffffff167fc4823739c5787d2ca17e404aa47d5569ae71dfb49cbf21b3f6152ed238a311398784604051808381526020018281526020019250505060405180910390a25050505050505050565b60003390506000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081111561431c5761431b8161406a565b5b614324612ea4565b5050565b60008060008060003390506000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050806000015481600101548260030160009054906101000a900462ffffff1683600201549550955095509550505090919293565b6143b233614f3a565b83156143c5576143c48383338461461d565b5b50505050565b6143d633348361168b565b5050565b6000808284019050838110156143ec57fe5b8091505092915050565b60008082848161440257fe5b0490508091505092915050565b60008282111561441b57fe5b818303905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156144ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806156cd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415614532576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806156866022913960400191505060405180910390fd5b80601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b60405180608001604052808562ffffff16420181526020018481526020018281526020018562ffffff16815250601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000155602082015181600101556040820151816002015560608201518160030160006101000a81548162ffffff021916908362ffffff1602179055509050508173ffffffffffffffffffffffffffffffffffffffff167f4bf1c14e646c965eb2b35b7e0d08e65d0044d5d5a1eaf7f80f5f161688c34579601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154858785604051808581526020018481526020018362ffffff1662ffffff16815260200182815260200194505050505060405180910390a250505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561480d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806156a86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415614893576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806156636023913960400191505060405180910390fd5b601060009054906101000a900460ff161580156148ef5750600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548111155b6148f857600080fd5b6000600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054614943856128f8565b0111156149545761495383614d28565b5b61495e8184615395565b600061496e82600a60ff166143f6565b9050600061497c838361440f565b9050600061498983613e48565b9050614997600d548461440f565b600d819055506149e6600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548561440f565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614a72600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836143da565b600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060405180606001604052808481526020014281526020016000815250908060018154018082558091505090600182039060005260206000209060030201600090919290919091506000820151816000015560208201518160010155604082015181600201555050506001600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001016000828254019250508190555083600e5402600b60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600e5402600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550614c70600e54614c6b8368010000000000000000600d54613b81565b6143da565b600e819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3505050505050565b60008060026001840181614cf357fe5b0490508291505b81811015614d2257809150600281828581614d1157fe5b040181614d1a57fe5b049050614cfa565b50919050565b6000614d33826128f8565b90506000600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054820111614d8357600080fd5b680100000000000000008102600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054810190506000600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008290508073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015614eaf573d6000803e3d6000fd5b508273ffffffffffffffffffffffffffffffffffffffff167fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc836040518082815260200191505060405180910390a2505050565b600080831415614f165760009050614f34565b6000828402905082848281614f2757fe5b0414614f2f57fe5b809150505b92915050565b6000614f45826128f8565b90506000600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054820111614f9557600080fd5b680100000000000000008102600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054810190506000600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006150848383600061168b565b90508273ffffffffffffffffffffffffffffffffffffffff167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab36153264588383604051808381526020018281526020019250505060405180910390a2505050565b6000806150ec6138a5565b116150f657600080fd5b60008090506000600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000154905060008090505b8260010154821161537f576000600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083815481106151a457fe5b9060005260206000209060030201905060006151c88260000154836002015461440f565b905060006151d68a8861440f565b90508082101561527e578187019650615204846151ff6151f9866001015461346d565b85614f03565b6143da565b9350600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020858154811061525057fe5b9060005260206000209060030201600080820160009055600182016000905560028201600090555050615371565b80821161532d576152a48461529f615299866001015461346d565b84614f03565b6143da565b9350600560008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002085815481106152f057fe5b906000526020600020906003020160008082016000905560018201600090556002820160009055505060018501866000018190555050505061537f565b61534c84615347615341866001015461346d565b84614f03565b6143da565b935080836002016000828254019250508190555084866000018190555050505061537f565b60018501945050505061514d565b61538981886143f6565b94505050505092915050565b60008090506000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000816000015490505b816001015481116155b6576000600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811061543e57fe5b9060005260206000209060030201905060006154628260000154836002015461440f565b90506000615470888761440f565b9050808210156154f7578186019550600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002084815481106154c957fe5b90600052602060002090600302016000808201600090556001820160009055600282016000905550506155a8565b80821161558557600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020848154811061554857fe5b90600052602060002090600302016000808201600090556001820160009055600282016000905550506001840185600001819055505050506155b6565b8083600201600082825401925050819055508385600001819055505050506155b6565b6001840193505050506153e7565b5050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106155fe57805160ff191683800117855561562c565b8280016001018555821561562c579182015b8281111561562b578251825591602001919060010190615610565b5b509050615639919061563d565b5090565b61565f91905b8082111561565b576000816000905550600101615643565b5090565b9056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a265627a7a723158202c4790f7928bf9a3a45a9f8993b6a67a03c0e30cb3eae470bc64181e301607b864736f6c634300050f0032
[ 4, 11, 18 ]
0xf3b65b2F5026118381B95EE3d1B6bf1e88F9E093
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0 <0.9.0; //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@* .*. &@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ &@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#/. &@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@%* #@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@. %@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@( /*@/ (@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@( (@*@@@&/./@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@, .#@@@@@@@@@@@@@%,./@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@, *@@@@@@@@@@@@# *@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@/ .**%@@@@@@, #@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@% ,. %@@@@/ ,@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@, &%, #@@@@( (@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@. ,/ (@@@@@, @@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@, @@@@@&. %@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@# /** .(#@@@@@@. &@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@* ,@&%&@@@@@@@@@@, %@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@. %@@@@@@@@@# *@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@. ,(#%%&&, *%&%%@@@@@@@@@@@# *@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@/ [email protected]@@@@@@@@@@@@&* #@@@@@@@@* #@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@% %@@@@@@@@@@@@@@@( #@@@@@@@* /@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@( /@@@@@@@@@@@@@@@@@@@@@@%. (@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@&, (@@@@@@@@@@@@@@@@@/ ,@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@* ,(%&&@@&&#* .(@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&%/. ,(&@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /// @title A contract for Genesis Fine Art Collection by ratDAO /// @author Phillip /// @notice NFT Minting contract ratDAOArt is ERC721, Ownable { // token ID uint16 private tokenId; // mapping for token URIs mapping(uint256 => string) private tokenURIs; // treasury wallet address address private treasury; constructor() ERC721("Genesis Fine Art Collection by ratDAO", "ART") { } /** * Mint Artwork */ function mint() external returns (string memory) { require(_msgSender() != address(0)); require(_msgSender() == owner() || _msgSender() == treasury, "Caller is not allowed to mint."); require(bytes(tokenURIs[tokenId + 1]).length != 0, "Next token does not exist."); tokenId++; _safeMint(_msgSender(), tokenId); return tokenURIs[tokenId]; } /** * Set Token URI * _tokenId must be in [1, tokenId + 1] */ function setTokenURI(uint256 _tokenId, string memory _tokenURI) external onlyOwner returns (string memory) { require(_tokenId > 0); require(_tokenId < tokenId + 2); tokenURIs[_tokenId] = _tokenURI; return tokenURIs[_tokenId]; } /** * Override tokenURI */ function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist"); return tokenURIs[_tokenId]; } /** * Set Treasury */ function setTreasury(address _treasury) external onlyOwner returns (address) { treasury = _treasury; return treasury; } /** * Get Treasury */ function getTreasury() external view onlyOwner returns (address) { return treasury; } /** * Get Token URI */ function getTokenURI(uint256 _tokenId) external view onlyOwner returns (string memory) { return tokenURIs[_tokenId]; } } // 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 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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); }
0x608060405234801561001057600080fd5b50600436106101175760003560e01c80636352211e116100a85780636352211e146101f557806370a0823114610208578063715018a6146102295780638da5cb5b1461023157806395d89b4114610239578063a22cb46514610241578063b88d4fde14610254578063c87b56dd14610267578063e985e9c51461027a578063f0f442601461028d578063f2fde38b146102a057600080fd5b806301ffc9a71461011c57806306fdde0314610144578063081812fc14610159578063095ea7b3146101845780631249c58b14610199578063162094c4146101a157806323b872dd146101b45780633b19e84a146101c75780633bb3a24d146101cf57806342842e0e146101e2575b600080fd5b61012f61012a3660046113cc565b6102b3565b60405190151581526020015b60405180910390f35b61014c610305565b60405161013b919061143d565b61016c610167366004611450565b610397565b6040516001600160a01b03909116815260200161013b565b610197610192366004611480565b610424565b005b61014c610535565b61014c6101af366004611536565b6106ca565b6101976101c2366004611591565b6107ef565b61016c610820565b61014c6101dd366004611450565b610861565b6101976101f0366004611591565b610931565b61016c610203366004611450565b61094c565b61021b6102163660046115cd565b6109c3565b60405190815260200161013b565b610197610a4a565b61016c610a85565b61014c610a94565b61019761024f3660046115e8565b610aa3565b610197610262366004611624565b610ab2565b61014c610275366004611450565b610aea565b61012f6102883660046116a0565b610b38565b61016c61029b3660046115cd565b610b66565b6101976102ae3660046115cd565b610bba565b60006001600160e01b031982166380ac58cd60e01b14806102e457506001600160e01b03198216635b5e139f60e01b145b806102ff57506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060008054610314906116d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610340906116d3565b801561038d5780601f106103625761010080835404028352916020019161038d565b820191906000526020600020905b81548152906001019060200180831161037057829003601f168201915b5050505050905090565b60006103a282610c5a565b6104085760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061042f8261094c565b9050806001600160a01b0316836001600160a01b0316141561049d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016103ff565b336001600160a01b03821614806104b957506104b98133610b38565b6105265760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b60648201526084016103ff565b6105308383610c77565b505050565b60603361054157600080fd5b610549610a85565b6001600160a01b0316336001600160a01b0316148061057b57506008546001600160a01b0316336001600160a01b0316145b6105c75760405162461bcd60e51b815260206004820152601e60248201527f43616c6c6572206973206e6f7420616c6c6f77656420746f206d696e742e000060448201526064016103ff565b6006546007906000906105e690600160a01b900461ffff166001611724565b61ffff1681526020019081526020016000208054610603906116d3565b151590506106505760405162461bcd60e51b815260206004820152601a6024820152792732bc3a103a37b5b2b7103237b2b9903737ba1032bc34b9ba1760311b60448201526064016103ff565b60068054600160a01b900461ffff1690601461066b8361174a565b91906101000a81548161ffff021916908361ffff160217905550506106a36106903390565b600654600160a01b900461ffff16610ce5565b600654600160a01b900461ffff1660009081526007602052604090208054610314906116d3565b6060336106d5610a85565b6001600160a01b0316146106fb5760405162461bcd60e51b81526004016103ff9061176c565b6000831161070857600080fd5b60065461072190600160a01b900461ffff166002611724565b61ffff16831061073057600080fd5b6000838152600760209081526040909120835161074f9285019061131d565b5060008381526007602052604090208054610769906116d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610795906116d3565b80156107e25780601f106107b7576101008083540402835291602001916107e2565b820191906000526020600020905b8154815290600101906020018083116107c557829003601f168201915b5050505050905092915050565b6107f93382610cff565b6108155760405162461bcd60e51b81526004016103ff906117a1565b610530838383610dc9565b60003361082b610a85565b6001600160a01b0316146108515760405162461bcd60e51b81526004016103ff9061176c565b506008546001600160a01b031690565b60603361086c610a85565b6001600160a01b0316146108925760405162461bcd60e51b81526004016103ff9061176c565b600082815260076020526040902080546108ab906116d3565b80601f01602080910402602001604051908101604052809291908181526020018280546108d7906116d3565b80156109245780601f106108f957610100808354040283529160200191610924565b820191906000526020600020905b81548152906001019060200180831161090757829003601f168201915b505050505090505b919050565b61053083838360405180602001604052806000815250610ab2565b6000818152600260205260408120546001600160a01b0316806102ff5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016103ff565b60006001600160a01b038216610a2e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016103ff565b506001600160a01b031660009081526003602052604090205490565b33610a53610a85565b6001600160a01b031614610a795760405162461bcd60e51b81526004016103ff9061176c565b610a836000610f69565b565b6006546001600160a01b031690565b606060018054610314906116d3565b610aae338383610fbb565b5050565b610abc3383610cff565b610ad85760405162461bcd60e51b81526004016103ff906117a1565b610ae484848484611086565b50505050565b6060610af582610c5a565b6108925760405162461bcd60e51b8152602060048201526014602482015273151bdad95b88191bd95cc81b9bdd08195e1a5cdd60621b60448201526064016103ff565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600033610b71610a85565b6001600160a01b031614610b975760405162461bcd60e51b81526004016103ff9061176c565b50600880546001600160a01b0319166001600160a01b0392909216918217905590565b33610bc3610a85565b6001600160a01b031614610be95760405162461bcd60e51b81526004016103ff9061176c565b6001600160a01b038116610c4e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103ff565b610c5781610f69565b50565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610cac8261094c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610aae8282604051806020016040528060008152506110b9565b6000610d0a82610c5a565b610d6b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016103ff565b6000610d768361094c565b9050806001600160a01b0316846001600160a01b03161480610db15750836001600160a01b0316610da684610397565b6001600160a01b0316145b80610dc15750610dc18185610b38565b949350505050565b826001600160a01b0316610ddc8261094c565b6001600160a01b031614610e445760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016103ff565b6001600160a01b038216610ea65760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016103ff565b610eb1600082610c77565b6001600160a01b0383166000908152600360205260408120805460019290610eda9084906117f2565b90915550506001600160a01b0382166000908152600360205260408120805460019290610f08908490611809565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031614156110195760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016103ff565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611091848484610dc9565b61109d848484846110ec565b610ae45760405162461bcd60e51b81526004016103ff90611821565b6110c383836111ea565b6110d060008484846110ec565b6105305760405162461bcd60e51b81526004016103ff90611821565b60006001600160a01b0384163b156111df57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611130903390899088908890600401611873565b6020604051808303816000875af192505050801561116b575060408051601f3d908101601f19168201909252611168918101906118b0565b60015b6111c5573d808015611199576040519150601f19603f3d011682016040523d82523d6000602084013e61119e565b606091505b5080516111bd5760405162461bcd60e51b81526004016103ff90611821565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610dc1565b506001949350505050565b6001600160a01b0382166112405760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016103ff565b61124981610c5a565b156112965760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016103ff565b6001600160a01b03821660009081526003602052604081208054600192906112bf908490611809565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611329906116d3565b90600052602060002090601f01602090048101928261134b5760008555611391565b82601f1061136457805160ff1916838001178555611391565b82800160010185558215611391579182015b82811115611391578251825591602001919060010190611376565b5061139d9291506113a1565b5090565b5b8082111561139d57600081556001016113a2565b6001600160e01b031981168114610c5757600080fd5b6000602082840312156113de57600080fd5b81356113e9816113b6565b9392505050565b6000815180845260005b81811015611416576020818501810151868301820152016113fa565b81811115611428576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006113e960208301846113f0565b60006020828403121561146257600080fd5b5035919050565b80356001600160a01b038116811461092c57600080fd5b6000806040838503121561149357600080fd5b61149c83611469565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156114db576114db6114aa565b604051601f8501601f19908116603f01168101908282118183101715611503576115036114aa565b8160405280935085815286868601111561151c57600080fd5b858560208301376000602087830101525050509392505050565b6000806040838503121561154957600080fd5b82359150602083013567ffffffffffffffff81111561156757600080fd5b8301601f8101851361157857600080fd5b611587858235602084016114c0565b9150509250929050565b6000806000606084860312156115a657600080fd5b6115af84611469565b92506115bd60208501611469565b9150604084013590509250925092565b6000602082840312156115df57600080fd5b6113e982611469565b600080604083850312156115fb57600080fd5b61160483611469565b91506020830135801515811461161957600080fd5b809150509250929050565b6000806000806080858703121561163a57600080fd5b61164385611469565b935061165160208601611469565b925060408501359150606085013567ffffffffffffffff81111561167457600080fd5b8501601f8101871361168557600080fd5b611694878235602084016114c0565b91505092959194509250565b600080604083850312156116b357600080fd5b6116bc83611469565b91506116ca60208401611469565b90509250929050565b600181811c908216806116e757607f821691505b6020821081141561170857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600061ffff8083168185168083038211156117415761174161170e565b01949350505050565b600061ffff808316818114156117625761176261170e565b6001019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000828210156118045761180461170e565b500390565b6000821982111561181c5761181c61170e565b500190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906118a6908301846113f0565b9695505050505050565b6000602082840312156118c257600080fd5b81516113e9816113b656fea2646970667358221220476e4930ac5860e4ed5095e1d317bd1a41e5da2f6672c2f084bdb982c238b21d64736f6c634300080b0033
[ 5 ]
0xF3b6840B89E72eC46c90132EBA581f851435ff63
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity >=0.7.0 <0.9.0; contract ICECREAMZ is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.02 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 5; bool public paused = false; bool public revealed = false; string public notRevealedUri; uint nofHidden = 9; 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; } // internal function randomHidden(uint number) internal view returns(uint){ return uint(keccak256(abi.encodePacked(number))) % nofHidden; } // internal function calculatePrice() public view returns (uint) { return calculatePriceForToken(totalSupply()); } // internal function calculatePriceForToken(uint _id) public pure returns (uint) { if (_id >= 9000) { return 0.1 ether; // 9000-10000: 0.10 ETH } else if (_id >= 5000) { return 0.08 ether; // 5000-9000: 0.08 ETH } else if (_id >= 2000) { return 0.06 ether; // 2000-5000: 0.06 ETH } else if (_id >= 1000) { return 0.04 ether; // 1000-2000: 0.04 ETH } else { return 0.02 ether; // 0 - 1000 0.02 ETH } } // 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 >= calculatePrice() * _mintAmount, "Not enough funds"); } 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 string(abi.encodePacked(notRevealedUri, (randomHidden(tokenId)+1).toString(), baseExtension)); } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
0x6080604052600436106102255760003560e01c80636352211e11610123578063a475b5dd116100ab578063d5abeb011161006f578063d5abeb0114610607578063da3ef23f1461061d578063e985e9c51461063d578063f2c4ce1e14610686578063f2fde38b146106a657600080fd5b8063a475b5dd14610588578063b88d4fde1461059d578063c6682862146105bd578063c87b56dd146105d2578063d348b409146105f257600080fd5b80637f00c7a6116100f25780637f00c7a6146105025780638da5cb5b1461052257806395d89b4114610540578063a0712d6814610555578063a22cb4651461056857600080fd5b80636352211e1461048d5780636fd9537f146104ad57806370a08231146104cd578063715018a6146104ed57600080fd5b806323b872dd116101b157806344a0d68a1161017557806344a0d68a146103f45780634f6ccce714610414578063518302271461043457806355f804b3146104535780635c975abb1461047357600080fd5b806323b872dd1461035f5780632f745c591461037f5780633ccfd60b1461039f57806342842e0e146103a7578063438b6300146103c757600080fd5b8063081c8c44116101f8578063081c8c44146102db578063095ea7b3146102f057806313faede61461031057806318160ddd14610334578063239c70ae1461034957600080fd5b806301ffc9a71461022a57806302329a291461025f57806306fdde0314610281578063081812fc146102a3575b600080fd5b34801561023657600080fd5b5061024a61024536600461205b565b6106c6565b60405190151581526020015b60405180910390f35b34801561026b57600080fd5b5061027f61027a366004612040565b6106f1565b005b34801561028d57600080fd5b50610296610737565b6040516102569190612297565b3480156102af57600080fd5b506102c36102be3660046120de565b6107c9565b6040516001600160a01b039091168152602001610256565b3480156102e757600080fd5b5061029661085e565b3480156102fc57600080fd5b5061027f61030b366004612016565b6108ec565b34801561031c57600080fd5b50610326600d5481565b604051908152602001610256565b34801561034057600080fd5b50600854610326565b34801561035557600080fd5b50610326600f5481565b34801561036b57600080fd5b5061027f61037a366004611f34565b610a02565b34801561038b57600080fd5b5061032661039a366004612016565b610a33565b61027f610ac9565b3480156103b357600080fd5b5061027f6103c2366004611f34565b610b67565b3480156103d357600080fd5b506103e76103e2366004611ee6565b610b82565b6040516102569190612253565b34801561040057600080fd5b5061027f61040f3660046120de565b610c24565b34801561042057600080fd5b5061032661042f3660046120de565b610c53565b34801561044057600080fd5b5060105461024a90610100900460ff1681565b34801561045f57600080fd5b5061027f61046e366004612095565b610ce6565b34801561047f57600080fd5b5060105461024a9060ff1681565b34801561049957600080fd5b506102c36104a83660046120de565b610d27565b3480156104b957600080fd5b506103266104c83660046120de565b610d9e565b3480156104d957600080fd5b506103266104e8366004611ee6565b610e11565b3480156104f957600080fd5b5061027f610e98565b34801561050e57600080fd5b5061027f61051d3660046120de565b610ece565b34801561052e57600080fd5b50600a546001600160a01b03166102c3565b34801561054c57600080fd5b50610296610efd565b61027f6105633660046120de565b610f0c565b34801561057457600080fd5b5061027f610583366004611fec565b610ff4565b34801561059457600080fd5b5061027f6110b9565b3480156105a957600080fd5b5061027f6105b8366004611f70565b6110f4565b3480156105c957600080fd5b5061029661112c565b3480156105de57600080fd5b506102966105ed3660046120de565b611139565b3480156105fe57600080fd5b5061032661126e565b34801561061357600080fd5b50610326600e5481565b34801561062957600080fd5b5061027f610638366004612095565b611281565b34801561064957600080fd5b5061024a610658366004611f01565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561069257600080fd5b5061027f6106a1366004612095565b6112be565b3480156106b257600080fd5b5061027f6106c1366004611ee6565b6112fb565b60006001600160e01b0319821663780e9d6360e01b14806106eb57506106eb82611393565b92915050565b600a546001600160a01b031633146107245760405162461bcd60e51b815260040161071b906122fc565b60405180910390fd5b6010805460ff1916911515919091179055565b60606000805461074690612410565b80601f016020809104026020016040519081016040528092919081815260200182805461077290612410565b80156107bf5780601f10610794576101008083540402835291602001916107bf565b820191906000526020600020905b8154815290600101906020018083116107a257829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108425760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161071b565b506000908152600460205260409020546001600160a01b031690565b6011805461086b90612410565b80601f016020809104026020016040519081016040528092919081815260200182805461089790612410565b80156108e45780601f106108b9576101008083540402835291602001916108e4565b820191906000526020600020905b8154815290600101906020018083116108c757829003601f168201915b505050505081565b60006108f782610d27565b9050806001600160a01b0316836001600160a01b031614156109655760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161071b565b336001600160a01b038216148061098157506109818133610658565b6109f35760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161071b565b6109fd83836113e3565b505050565b610a0c3382611451565b610a285760405162461bcd60e51b815260040161071b90612331565b6109fd838383611548565b6000610a3e83610e11565b8210610aa05760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161071b565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610af35760405162461bcd60e51b815260040161071b906122fc565b6000610b07600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b51576040519150601f19603f3d011682016040523d82523d6000602084013e610b56565b606091505b5050905080610b6457600080fd5b50565b6109fd838383604051806020016040528060008152506110f4565b60606000610b8f83610e11565b905060008167ffffffffffffffff811115610bac57610bac6124d2565b604051908082528060200260200182016040528015610bd5578160200160208202803683370190505b50905060005b82811015610c1c57610bed8582610a33565b828281518110610bff57610bff6124bc565b602090810291909101015280610c148161244b565b915050610bdb565b509392505050565b600a546001600160a01b03163314610c4e5760405162461bcd60e51b815260040161071b906122fc565b600d55565b6000610c5e60085490565b8210610cc15760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161071b565b60088281548110610cd457610cd46124bc565b90600052602060002001549050919050565b600a546001600160a01b03163314610d105760405162461bcd60e51b815260040161071b906122fc565b8051610d2390600b906020840190611db0565b5050565b6000818152600260205260408120546001600160a01b0316806106eb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161071b565b60006123288210610db8575067016345785d8a0000919050565b6113888210610dd0575067011c37937e080000919050565b6107d08210610de7575066d529ae9e860000919050565b6103e88210610dfe5750668e1bc9bf040000919050565b5066470de4df820000919050565b919050565b60006001600160a01b038216610e7c5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161071b565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610ec25760405162461bcd60e51b815260040161071b906122fc565b610ecc60006116f3565b565b600a546001600160a01b03163314610ef85760405162461bcd60e51b815260040161071b906122fc565b600f55565b60606001805461074690612410565b6000610f1760085490565b60105490915060ff1615610f2a57600080fd5b60008211610f3757600080fd5b600f54821115610f4657600080fd5b600e54610f538383612382565b1115610f5e57600080fd5b600a546001600160a01b03163314610fc55781610f7961126e565b610f8391906123ae565b341015610fc55760405162461bcd60e51b815260206004820152601060248201526f4e6f7420656e6f7567682066756e647360801b604482015260640161071b565b60015b8281116109fd57610fe233610fdd8385612382565b611745565b80610fec8161244b565b915050610fc8565b6001600160a01b03821633141561104d5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161071b565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b031633146110e35760405162461bcd60e51b815260040161071b906122fc565b6010805461ff001916610100179055565b6110fe3383611451565b61111a5760405162461bcd60e51b815260040161071b90612331565b6111268484848461175f565b50505050565b600c805461086b90612410565b6000818152600260205260409020546060906001600160a01b03166111b85760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071b565b601054610100900460ff1661120f5760116111e56111d584611792565b6111e0906001612382565b6117cd565b600c6040516020016111f9939291906121fa565b6040516020818303038152906040529050919050565b60006112196118cb565b905060008151116112395760405180602001604052806000815250611267565b80611243846117cd565b600c604051602001611257939291906121bd565b6040516020818303038152906040525b9392505050565b600061127c6104c860085490565b905090565b600a546001600160a01b031633146112ab5760405162461bcd60e51b815260040161071b906122fc565b8051610d2390600c906020840190611db0565b600a546001600160a01b031633146112e85760405162461bcd60e51b815260040161071b906122fc565b8051610d23906011906020840190611db0565b600a546001600160a01b031633146113255760405162461bcd60e51b815260040161071b906122fc565b6001600160a01b03811661138a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161071b565b610b64816116f3565b60006001600160e01b031982166380ac58cd60e01b14806113c457506001600160e01b03198216635b5e139f60e01b145b806106eb57506301ffc9a760e01b6001600160e01b03198316146106eb565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061141882610d27565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166114ca5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161071b565b60006114d583610d27565b9050806001600160a01b0316846001600160a01b031614806115105750836001600160a01b0316611505846107c9565b6001600160a01b0316145b8061154057506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661155b82610d27565b6001600160a01b0316146115c35760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161071b565b6001600160a01b0382166116255760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161071b565b6116308383836118da565b61163b6000826113e3565b6001600160a01b03831660009081526003602052604081208054600192906116649084906123cd565b90915550506001600160a01b0382166000908152600360205260408120805460019290611692908490612382565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610d23828260405180602001604052806000815250611992565b61176a848484611548565b611776848484846119c5565b6111265760405162461bcd60e51b815260040161071b906122aa565b6000601254826040516020016117aa91815260200190565b6040516020818303038152906040528051906020012060001c6106eb9190612466565b6060816117f15750506040805180820190915260018152600360fc1b602082015290565b8160005b811561181b57806118058161244b565b91506118149050600a8361239a565b91506117f5565b60008167ffffffffffffffff811115611836576118366124d2565b6040519080825280601f01601f191660200182016040528015611860576020820181803683370190505b5090505b8415611540576118756001836123cd565b9150611882600a86612466565b61188d906030612382565b60f81b8183815181106118a2576118a26124bc565b60200101906001600160f81b031916908160001a9053506118c4600a8661239a565b9450611864565b6060600b805461074690612410565b6001600160a01b0383166119355761193081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611958565b816001600160a01b0316836001600160a01b031614611958576119588382611ad2565b6001600160a01b03821661196f576109fd81611b6f565b826001600160a01b0316826001600160a01b0316146109fd576109fd8282611c1e565b61199c8383611c62565b6119a960008484846119c5565b6109fd5760405162461bcd60e51b815260040161071b906122aa565b60006001600160a01b0384163b15611ac757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611a09903390899088908890600401612216565b602060405180830381600087803b158015611a2357600080fd5b505af1925050508015611a53575060408051601f3d908101601f19168201909252611a5091810190612078565b60015b611aad573d808015611a81576040519150601f19603f3d011682016040523d82523d6000602084013e611a86565b606091505b508051611aa55760405162461bcd60e51b815260040161071b906122aa565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611540565b506001949350505050565b60006001611adf84610e11565b611ae991906123cd565b600083815260076020526040902054909150808214611b3c576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611b81906001906123cd565b60008381526009602052604081205460088054939450909284908110611ba957611ba96124bc565b906000526020600020015490508060088381548110611bca57611bca6124bc565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611c0257611c026124a6565b6001900381819060005260206000200160009055905550505050565b6000611c2983610e11565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611cb85760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161071b565b6000818152600260205260409020546001600160a01b031615611d1d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161071b565b611d29600083836118da565b6001600160a01b0382166000908152600360205260408120805460019290611d52908490612382565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611dbc90612410565b90600052602060002090601f016020900481019282611dde5760008555611e24565b82601f10611df757805160ff1916838001178555611e24565b82800160010185558215611e24579182015b82811115611e24578251825591602001919060010190611e09565b50611e30929150611e34565b5090565b5b80821115611e305760008155600101611e35565b600067ffffffffffffffff80841115611e6457611e646124d2565b604051601f8501601f19908116603f01168101908282118183101715611e8c57611e8c6124d2565b81604052809350858152868686011115611ea557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114610e0c57600080fd5b80358015158114610e0c57600080fd5b600060208284031215611ef857600080fd5b61126782611ebf565b60008060408385031215611f1457600080fd5b611f1d83611ebf565b9150611f2b60208401611ebf565b90509250929050565b600080600060608486031215611f4957600080fd5b611f5284611ebf565b9250611f6060208501611ebf565b9150604084013590509250925092565b60008060008060808587031215611f8657600080fd5b611f8f85611ebf565b9350611f9d60208601611ebf565b925060408501359150606085013567ffffffffffffffff811115611fc057600080fd5b8501601f81018713611fd157600080fd5b611fe087823560208401611e49565b91505092959194509250565b60008060408385031215611fff57600080fd5b61200883611ebf565b9150611f2b60208401611ed6565b6000806040838503121561202957600080fd5b61203283611ebf565b946020939093013593505050565b60006020828403121561205257600080fd5b61126782611ed6565b60006020828403121561206d57600080fd5b8135611267816124e8565b60006020828403121561208a57600080fd5b8151611267816124e8565b6000602082840312156120a757600080fd5b813567ffffffffffffffff8111156120be57600080fd5b8201601f810184136120cf57600080fd5b61154084823560208401611e49565b6000602082840312156120f057600080fd5b5035919050565b6000815180845261210f8160208601602086016123e4565b601f01601f19169290920160200192915050565b8054600090600181811c908083168061213d57607f831692505b602080841082141561215f57634e487b7160e01b600052602260045260246000fd5b8180156121735760018114612184576121b1565b60ff198616895284890196506121b1565b60008881526020902060005b868110156121a95781548b820152908501908301612190565b505084890196505b50505050505092915050565b600084516121cf8184602089016123e4565b8451908301906121e38183602089016123e4565b6121ef81830186612123565b979650505050505050565b60006122068286612123565b84516121e38183602089016123e4565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612249908301846120f7565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561228b5783518352928401929184019160010161226f565b50909695505050505050565b60208152600061126760208301846120f7565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156123955761239561247a565b500190565b6000826123a9576123a9612490565b500490565b60008160001904831182151516156123c8576123c861247a565b500290565b6000828210156123df576123df61247a565b500390565b60005b838110156123ff5781810151838201526020016123e7565b838111156111265750506000910152565b600181811c9082168061242457607f821691505b6020821081141561244557634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561245f5761245f61247a565b5060010190565b60008261247557612475612490565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610b6457600080fdfea2646970667358221220455a5dfce853a94e8e99d61f564b929abeacd9a7bf8eac2bb9a9dfb8d0f6bd8364736f6c63430008070033
[ 5, 12 ]
0xF3B685d24f84b6eEeEeE334250cf73aDE1f10144
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; /// @title Claimable contract interface interface IClaimable { function owner() external view returns (address); function transferOwnership(address newOwner) external; function acceptOwnership() external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IClaimable.sol"; /// @title Mintable Token interface interface IMintableToken is IERC20, IClaimable { function issue(address to, uint256 amount) external; function destroy(address from, uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.12; import "./IMintableToken.sol"; /// @title The interface for mintable/burnable token governance. interface ITokenGovernance { // The address of the mintable ERC20 token. function token() external view returns (IMintableToken); /// @dev Mints new tokens. /// /// @param to Account to receive the new amount. /// @param amount Amount to increase the supply by. /// function mint(address to, uint256 amount) external; /// @dev Burns tokens from the caller. /// /// @param amount Amount to decrease the supply by. /// function burn(uint256 amount) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { function __AccessControlEnumerable_init() internal onlyInitializing { } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual 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 virtual 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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _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 virtual 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 virtual { 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 virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ 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()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _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()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // 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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (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: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, 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: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _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 Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/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/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/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (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: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; /** * @dev extends the SafeERC20 library with additional operations */ library SafeERC20Ex { using SafeERC20 for IERC20; /** * @dev ensures that the spender has sufficient allowance */ function ensureApprove( IERC20 token, address spender, uint256 amount ) internal { if (amount == 0) { return; } uint256 allowance = token.allowance(address(this), spender); if (allowance >= amount) { return; } if (allowance > 0) { token.safeApprove(spender, 0); } token.safeApprove(spender, amount); } } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; /** * @dev the main purpose of the Token interfaces is to ensure artificially that we won't use ERC20's standard functions, * but only their safe versions, which are provided by SafeERC20 and SafeERC20Ex via the TokenLibrary contract */ interface Token { } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol"; import { SafeERC20Ex } from "./SafeERC20Ex.sol"; import { Token } from "./Token.sol"; struct Signature { uint8 v; bytes32 r; bytes32 s; } /** * @dev This library implements ERC20 and SafeERC20 utilities for both the native token and for ERC20 tokens */ library TokenLibrary { using SafeERC20 for IERC20; using SafeERC20Ex for IERC20; error PermitUnsupported(); // the address that represents the native token reserve address public constant NATIVE_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // the symbol that represents the native token string private constant NATIVE_TOKEN_SYMBOL = "ETH"; // the decimals for the native token uint8 private constant NATIVE_TOKEN_DECIMALS = 18; /** * @dev returns whether the provided token represents an ERC20 or the native token reserve */ function isNative(Token token) internal pure returns (bool) { return address(token) == NATIVE_TOKEN_ADDRESS; } /** * @dev returns the symbol of the native token/ERC20 token */ function symbol(Token token) internal view returns (string memory) { if (isNative(token)) { return NATIVE_TOKEN_SYMBOL; } return toERC20(token).symbol(); } /** * @dev returns the decimals of the native token/ERC20 token */ function decimals(Token token) internal view returns (uint8) { if (isNative(token)) { return NATIVE_TOKEN_DECIMALS; } return toERC20(token).decimals(); } /** * @dev returns the balance of the native token/ERC20 token */ function balanceOf(Token token, address account) internal view returns (uint256) { if (isNative(token)) { return account.balance; } return toIERC20(token).balanceOf(account); } /** * @dev transfers a specific amount of the native token/ERC20 token */ function safeTransfer( Token token, address to, uint256 amount ) internal { if (amount == 0) { return; } if (isNative(token)) { payable(to).transfer(amount); } else { toIERC20(token).safeTransfer(to, amount); } } /** * @dev transfers a specific amount of the native token/ERC20 token from a specific holder using the allowance mechanism * * note that the function does not perform any action if the native token is provided */ function safeTransferFrom( Token token, address from, address to, uint256 amount ) internal { if (amount == 0 || isNative(token)) { return; } toIERC20(token).safeTransferFrom(from, to, amount); } /** * @dev approves a specific amount of the native token/ERC20 token from a specific holder * * note that the function does not perform any action if the native token is provided */ function safeApprove( Token token, address spender, uint256 amount ) internal { if (isNative(token)) { return; } toIERC20(token).safeApprove(spender, amount); } /** * @dev ensures that the spender has sufficient allowance * * note that the function does not perform any action if the native token is provided */ function ensureApprove( Token token, address spender, uint256 amount ) internal { if (isNative(token)) { return; } toIERC20(token).ensureApprove(spender, amount); } /** * @dev performs an EIP2612 permit */ function permit( Token token, address owner, address spender, uint256 tokenAmount, uint256 deadline, Signature memory signature ) internal { if (isNative(token)) { revert PermitUnsupported(); } // permit the amount the owner is trying to deposit. Please note, that if the base token doesn't support // EIP2612 permit - either this call or the inner safeTransferFrom will revert IERC20Permit(address(token)).permit( owner, spender, tokenAmount, deadline, signature.v, signature.r, signature.s ); } /** * @dev compares between a token and another raw ERC20 token */ function isEqual(Token token, IERC20 erc20Token) internal pure returns (bool) { return toIERC20(token) == erc20Token; } /** * @dev utility function that converts an token to an IERC20 */ function toIERC20(Token token) internal pure returns (IERC20) { return IERC20(address(token)); } /** * @dev utility function that converts an token to an ERC20 */ function toERC20(Token token) internal pure returns (ERC20) { return ERC20(address(token)); } } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; /** * @dev burnable ERC20 interface */ interface IERC20Burnable { /** * @dev Destroys tokens from the caller. */ function burn(uint256 amount) external; /** * @dev Destroys tokens from a recipient, deducting from the caller's allowance * * requirements: * * - the caller must have allowance for recipient's tokens of at least the specified amount */ function burnFrom(address recipient, uint256 amount) external; } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; uint32 constant PPM_RESOLUTION = 1000000; // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { AccessControlEnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import { IUpgradeable } from "./interfaces/IUpgradeable.sol"; import { AccessDenied } from "./Utils.sol"; /** * @dev this contract provides common utilities for upgradeable contracts */ abstract contract Upgradeable is IUpgradeable, AccessControlEnumerableUpgradeable { error AlreadyInitialized(); // the admin role is used to allow a non-proxy admin to perform additional initialization/setup during contract // upgrades bytes32 internal constant ROLE_ADMIN = keccak256("ROLE_ADMIN"); uint32 internal constant MAX_GAP = 50; uint16 internal _initializations; // upgrade forward-compatibility storage gap uint256[MAX_GAP - 1] private __gap; // solhint-disable func-name-mixedcase /** * @dev initializes the contract and its parents */ function __Upgradeable_init() internal onlyInitializing { __AccessControl_init(); __Upgradeable_init_unchained(); } /** * @dev performs contract-specific initialization */ function __Upgradeable_init_unchained() internal onlyInitializing { _initializations = 1; // set up administrative roles _setRoleAdmin(ROLE_ADMIN, ROLE_ADMIN); // allow the deployer to initially be the admin of the contract _setupRole(ROLE_ADMIN, msg.sender); } // solhint-enable func-name-mixedcase modifier onlyAdmin() { _hasRole(ROLE_ADMIN, msg.sender); _; } modifier onlyRoleMember(bytes32 role) { _hasRole(role, msg.sender); _; } function version() public view virtual override returns (uint16); /** * @dev returns the admin role */ function roleAdmin() external pure returns (bytes32) { return ROLE_ADMIN; } /** * @dev performs post-upgrade initialization * * requirements: * * - this must can be called only once per-upgrade */ function postUpgrade(bytes calldata data) external { uint16 initializations = _initializations + 1; if (initializations != version()) { revert AlreadyInitialized(); } _initializations = initializations; _postUpgrade(data); } /** * @dev an optional post-upgrade callback that can be implemented by child contracts */ function _postUpgrade( bytes calldata /* data */ ) internal virtual {} function _hasRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert AccessDenied(); } } } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { PPM_RESOLUTION } from "./Constants.sol"; error AccessDenied(); error AlreadyExists(); error DoesNotExist(); error InvalidAddress(); error InvalidExternalAddress(); error InvalidFee(); error InvalidPool(); error InvalidPoolCollection(); error InvalidStakedBalance(); error InvalidToken(); error InvalidType(); error InvalidParam(); error NotEmpty(); error NotPayable(); error ZeroValue(); /** * @dev common utilities */ contract Utils { // allows execution by the caller only modifier only(address caller) { _only(caller); _; } function _only(address caller) internal view { if (msg.sender != caller) { revert AccessDenied(); } } // verifies that a value is greater than zero modifier greaterThanZero(uint256 value) { _greaterThanZero(value); _; } // error message binary size optimization function _greaterThanZero(uint256 value) internal pure { if (value == 0) { revert ZeroValue(); } } // validates an address - currently only checks that it isn't null modifier validAddress(address addr) { _validAddress(addr); _; } // error message binary size optimization function _validAddress(address addr) internal pure { if (addr == address(0)) { revert InvalidAddress(); } } // validates an external address - currently only checks that it isn't null or this modifier validExternalAddress(address addr) { _validExternalAddress(addr); _; } // error message binary size optimization function _validExternalAddress(address addr) internal view { if (addr == address(0) || addr == address(this)) { revert InvalidExternalAddress(); } } // ensures that the fee is valid modifier validFee(uint32 fee) { _validFee(fee); _; } // error message binary size optimization function _validFee(uint32 fee) internal pure { if (fee > PPM_RESOLUTION) { revert InvalidFee(); } } } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { IVersioned } from "./IVersioned.sol"; import { IAccessControlEnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/IAccessControlEnumerableUpgradeable.sol"; /** * @dev this is the common interface for upgradeable contracts */ interface IUpgradeable is IAccessControlEnumerableUpgradeable, IVersioned { } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; /** * @dev an interface for a versioned contract */ interface IVersioned { function version() external view returns (uint16); } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ITokenGovernance } from "@bancor/token-governance/contracts/ITokenGovernance.sol"; import { IVersioned } from "../utility/interfaces/IVersioned.sol"; import { Upgradeable } from "../utility/Upgradeable.sol"; import { Token } from "../token/Token.sol"; import { TokenLibrary } from "../token/TokenLibrary.sol"; import { IMasterVault } from "./interfaces/IMasterVault.sol"; import { IVault, ROLE_ASSET_MANAGER } from "./interfaces/IVault.sol"; import { Vault } from "./Vault.sol"; /** * @dev Master Vault contract */ contract MasterVault is IMasterVault, Vault { using SafeERC20 for IERC20; using TokenLibrary for Token; // the BNT manager role is only required to access the BNT reserve bytes32 private constant ROLE_BNT_MANAGER = keccak256("ROLE_BNT_MANAGER"); // upgrade forward-compatibility storage gap uint256[MAX_GAP - 0] private __gap; /** * @dev a "virtual" constructor that is only used to set immutable state variables */ constructor(ITokenGovernance initBNTGovernance, ITokenGovernance initVBNTGovernance) Vault(initBNTGovernance, initVBNTGovernance) {} /** * @dev fully initializes the contract and its parents */ function initialize() external initializer { __MasterVault_init(); } // solhint-disable func-name-mixedcase /** * @dev initializes the contract and its parents */ function __MasterVault_init() internal onlyInitializing { __Vault_init(); __MasterVault_init_unchained(); } /** * @dev performs contract-specific initialization */ function __MasterVault_init_unchained() internal onlyInitializing { // set up administrative roles _setRoleAdmin(ROLE_ASSET_MANAGER, ROLE_ADMIN); _setRoleAdmin(ROLE_BNT_MANAGER, ROLE_ADMIN); } // solhint-enable func-name-mixedcase /** * @inheritdoc Upgradeable */ function version() public pure override(IVersioned, Upgradeable) returns (uint16) { return 1; } /** * @inheritdoc Vault */ function isPayable() public pure override(IVault, Vault) returns (bool) { return true; } /** * @dev returns the BNT manager role */ function roleBNTManager() external pure returns (bytes32) { return ROLE_BNT_MANAGER; } /** * @dev authorize the right of a caller to withdraw a specific amount of a token to a target * * requirements: * * - BNT: the caller must have the ROLE_BNT_MANAGER or ROLE_ASSET_MANAGER role * - other reserve token or the native token: the caller must have the ROLE_ASSET_MANAGER role */ function isAuthorizedWithdrawal( address caller, Token token, address, /* target */ uint256 /* amount */ ) internal view override returns (bool) { return (token.isEqual(_bnt) && hasRole(ROLE_BNT_MANAGER, caller)) || hasRole(ROLE_ASSET_MANAGER, caller); } } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import { ITokenGovernance } from "@bancor/token-governance/contracts/ITokenGovernance.sol"; import { IVault, ROLE_ASSET_MANAGER } from "./interfaces/IVault.sol"; import { Upgradeable } from "../utility/Upgradeable.sol"; import { IERC20Burnable } from "../token/interfaces/IERC20Burnable.sol"; import { Token } from "../token/Token.sol"; import { TokenLibrary } from "../token/TokenLibrary.sol"; import { Utils, AccessDenied, NotPayable, InvalidToken } from "../utility/Utils.sol"; abstract contract Vault is IVault, Upgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, Utils { using Address for address payable; using SafeERC20 for IERC20; using TokenLibrary for Token; // the address of the BNT token IERC20 internal immutable _bnt; // the address of the BNT token governance ITokenGovernance internal immutable _bntGovernance; // the address of the VBNT token IERC20 internal immutable _vbnt; // the address of the VBNT token governance ITokenGovernance internal immutable _vbntGovernance; // solhint-disable func-name-mixedcase /** * @dev a "virtual" constructor that is only used to set immutable state variables */ constructor(ITokenGovernance initBNTGovernance, ITokenGovernance initVBNTGovernance) validAddress(address(initBNTGovernance)) validAddress(address(initVBNTGovernance)) { _bntGovernance = initBNTGovernance; _bnt = initBNTGovernance.token(); _vbntGovernance = initVBNTGovernance; _vbnt = initVBNTGovernance.token(); } /** * @dev initializes the contract and its parents */ function __Vault_init() internal onlyInitializing { __Upgradeable_init(); __Pausable_init(); __ReentrancyGuard_init(); __Vault_init_unchained(); } /** * @dev performs contract-specific initialization */ function __Vault_init_unchained() internal onlyInitializing {} // solhint-enable func-name-mixedcase /** * @dev returns the asset manager role */ function roleAssetManager() external pure returns (bytes32) { return ROLE_ASSET_MANAGER; } // allows execution only by an authorized operation modifier whenAuthorized( address caller, Token token, address payable target, uint256 amount ) { if (!isAuthorizedWithdrawal(caller, token, target, amount)) { revert AccessDenied(); } _; } /** * @dev returns whether withdrawals are currently paused */ function isPaused() external view returns (bool) { return paused(); } /** * @dev pauses withdrawals * * requirements: * * - the caller must have the ROLE_ADMIN privileges */ function pause() external onlyAdmin { _pause(); } /** * @dev unpauses withdrawals * * requirements: * * - the caller must have the ROLE_ADMIN privileges */ function unpause() external onlyAdmin { _unpause(); } /** * @inheritdoc IVault */ function withdrawFunds( Token token, address payable target, uint256 amount ) external override validAddress(target) nonReentrant whenNotPaused whenAuthorized(msg.sender, token, target, amount) { if (amount == 0) { return; } if (token.isNative()) { // using a regular transfer here would revert due to exceeding the 2300 gas limit which is why we're using // call instead (via sendValue), which the 2300 gas limit does not apply for target.sendValue(amount); } else { token.safeTransfer(target, amount); } emit FundsWithdrawn({ token: token, caller: msg.sender, target: target, amount: amount }); } /** * @inheritdoc IVault */ function burn(Token token, uint256 amount) external nonReentrant whenNotPaused whenAuthorized(msg.sender, token, payable(address(0)), amount) { if (amount == 0) { return; } if (token.isNative()) { revert InvalidToken(); } // allow vaults to burn BNT and VBNT via their respective token governance modules if (token.isEqual(_bnt)) { _bntGovernance.burn(amount); } else if (token.isEqual(_vbnt)) { _vbntGovernance.burn(amount); } else { IERC20Burnable(address(token)).burn(amount); } emit FundsBurned({ token: token, caller: msg.sender, amount: amount }); } /** * @dev returns whether the given caller is allowed access to the given token */ function isAuthorizedWithdrawal( address caller, Token token, address target, uint256 amount ) internal view virtual returns (bool); /** * @inheritdoc IVault */ function isPayable() public view virtual returns (bool); /** * @dev authorize the contract to receive the native token * * requirements: * * - isPayable must return true */ receive() external payable { if (!isPayable()) { revert NotPayable(); } } } // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { IVault } from "./IVault.sol"; interface IMasterVault is IVault {} // SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.8.13; import { IUpgradeable } from "../../utility/interfaces/IUpgradeable.sol"; import { Token } from "../../token/Token.sol"; // the asset manager role is required to access all the funds bytes32 constant ROLE_ASSET_MANAGER = keccak256("ROLE_ASSET_MANAGER"); interface IVault is IUpgradeable { /** * @dev triggered when tokens have been withdrawn from the vault */ event FundsWithdrawn(Token indexed token, address indexed caller, address indexed target, uint256 amount); /** * @dev triggered when tokens have been burned from the vault */ event FundsBurned(Token indexed token, address indexed caller, uint256 amount); /** * @dev tells whether the vault accepts native token deposits */ function isPayable() external view returns (bool); /** * @dev withdraws funds held by the contract and sends them to an account */ function withdrawFunds( Token token, address payable target, uint256 amount ) external; /** * @dev burns funds held by the contract */ function burn(Token token, uint256 amount) external; }
0x6080604052600436106101395760003560e01c80639010d07c116100ab578063a217fddf1161006f578063a217fddf14610379578063b187bd261461038e578063c878ab33146103a3578063ca15c873146103d6578063ce46e046146103f6578063d547741f1461040a57600080fd5b80639010d07c146102ad57806391d14854146102e557806392bd95ea1461030557806393867fb5146103385780639dc29fac1461035957600080fd5b80633f4ba83a116100fd5780633f4ba83a1461021a57806354fd4d501461022f5780635c975abb1461024b5780638129fc1c146102635780638456cb59146102785780638cd2403d1461028d57600080fd5b806301ffc9a7146101475780631c20fadd1461017c578063248a9ca31461019c5780632f2ff15d146101da57806336568abe146101fa57600080fd5b3661014257005b005b600080fd5b34801561015357600080fd5b5061016761016236600461193f565b61042a565b60405190151581526020015b60405180910390f35b34801561018857600080fd5b5061014061019736600461197e565b610455565b3480156101a857600080fd5b506101cc6101b73660046119bf565b60009081526065602052604090206001015490565b604051908152602001610173565b3480156101e657600080fd5b506101406101f53660046119d8565b6105cb565b34801561020657600080fd5b506101406102153660046119d8565b6105f6565b34801561022657600080fd5b50610140610674565b34801561023b57600080fd5b5060405160018152602001610173565b34801561025757600080fd5b5060fb5460ff16610167565b34801561026f57600080fd5b50610140610696565b34801561028457600080fd5b50610140610757565b34801561029957600080fd5b506101406102a8366004611a08565b610777565b3480156102b957600080fd5b506102cd6102c8366004611a7a565b6107c8565b6040516001600160a01b039091168152602001610173565b3480156102f157600080fd5b506101676103003660046119d8565b6107e7565b34801561031157600080fd5b507f89ce14d20697a788f57260f7690044299bde7ea88cfb7e43d120a0c031f1ffc16101cc565b34801561034457600080fd5b50600080516020611d338339815191526101cc565b34801561036557600080fd5b50610140610374366004611a9c565b610812565b34801561038557600080fd5b506101cc600081565b34801561039a57600080fd5b50610167610adc565b3480156103af57600080fd5b507f4cbb5676e6e25e1a3b8a36de10472bcac96f97bd8dd87af6f330881b84739eb86101cc565b3480156103e257600080fd5b506101cc6103f13660046119bf565b610aef565b34801561040257600080fd5b506001610167565b34801561041657600080fd5b506101406104253660046119d8565b610b06565b60006001600160e01b03198216635a05180f60e01b148061044f575061044f82610b2c565b92915050565b8161045f81610b61565b600261012d54036104b75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600261012d5560fb5460ff16156104e05760405162461bcd60e51b81526004016104ae90611ac8565b338484846104f084848484610b88565b61050d57604051634ca8886760e01b815260040160405180910390fd5b85156105bb5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0389160361054f5761054a6001600160a01b03881687610c24565b610563565b6105636001600160a01b0389168888610d3d565b866001600160a01b0316336001600160a01b0316896001600160a01b03167fc322efa58c9cb2c39cfffdac61d35c8643f5cbf13c6a7d0034de2cf18923aff3896040516105b291815260200190565b60405180910390a45b5050600161012d55505050505050565b6000828152606560205260409020600101546105e78133610dbe565b6105f18383610e22565b505050565b6001600160a01b03811633146106665760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016104ae565b6106708282610e44565b5050565b61068c600080516020611d3383398151915233610e66565b610694610e8d565b565b600054610100900460ff166106b15760005460ff16156106b5565b303b155b6107185760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104ae565b600054610100900460ff1615801561073a576000805461ffff19166101011790555b610742610f20565b8015610754576000805461ff00191690555b50565b61076f600080516020611d3383398151915233610e66565b610694610f57565b60c95460009061078c9061ffff166001611b08565b905061ffff81166001146107b25760405162dc149f60e41b815260040160405180910390fd5b60c9805461ffff191661ffff8316179055505050565b60008281526097602052604081206107e09083610faf565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600261012d54036108655760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104ae565b600261012d5560fb5460ff161561088e5760405162461bcd60e51b81526004016104ae90611ac8565b338260008361089f84848484610b88565b6108bc57604051634ca8886760e01b815260040160405180910390fd5b8415610ace5773eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b038716036108ff5760405163c1ab6dc160e01b815260040160405180910390fd5b6001600160a01b037f0000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c8116908716036109b257604051630852cd8d60e31b8152600481018690527f000000000000000000000000a489c2b5b36835a327851ab917a80562b5afc2446001600160a01b0316906342966c68906024015b600060405180830381600087803b15801561099557600080fd5b505af11580156109a9573d6000803e3d6000fd5b50505050610a8d565b6001600160a01b037f00000000000000000000000048fb253446873234f2febbf9bdeaa72d9d387f94811690871603610a3257604051630852cd8d60e31b8152600481018690527f0000000000000000000000000887ae1251e180d7d453aedebee26e1639f201136001600160a01b0316906342966c689060240161097b565b604051630852cd8d60e31b8152600481018690526001600160a01b038716906342966c6890602401600060405180830381600087803b158015610a7457600080fd5b505af1158015610a88573d6000803e3d6000fd5b505050505b60405185815233906001600160a01b038816907fd3fda22e13f8cb743a9ceaca6e14022b6677188d20f3c3047f5c9033e07a4e879060200160405180910390a35b5050600161012d5550505050565b6000610aea60fb5460ff1690565b905090565b600081815260976020526040812061044f90610fbb565b600082815260656020526040902060010154610b228133610dbe565b6105f18383610e44565b60006001600160e01b03198216637965db0b60e01b148061044f57506301ffc9a760e01b6001600160e01b031983161461044f565b6001600160a01b0381166107545760405163e6c4247b60e01b815260040160405180910390fd5b60007f0000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c6001600160a01b03908116908516148015610beb5750610beb7f4cbb5676e6e25e1a3b8a36de10472bcac96f97bd8dd87af6f330881b84739eb8866107e7565b80610c1b5750610c1b7f89ce14d20697a788f57260f7690044299bde7ea88cfb7e43d120a0c031f1ffc1866107e7565b95945050505050565b80471015610c745760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016104ae565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610cc1576040519150601f19603f3d011682016040523d82523d6000602084013e610cc6565b606091505b50509050806105f15760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016104ae565b80600003610d4a57505050565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b03841603610daa576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610da4573d6000803e3d6000fd5b50505050565b6105f16001600160a01b0384168383610fc5565b610dc882826107e7565b61067057610de0816001600160a01b03166014611017565b610deb836020611017565b604051602001610dfc929190611b5a565b60408051601f198184030181529082905262461bcd60e51b82526104ae91600401611bcf565b610e2c82826111b3565b60008281526097602052604090206105f19082611239565b610e4e828261124e565b60008281526097602052604090206105f190826112b5565b610e7082826107e7565b61067057604051634ca8886760e01b815260040160405180910390fd5b60fb5460ff16610ed65760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016104ae565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600054610100900460ff16610f475760405162461bcd60e51b81526004016104ae90611c02565b610f4f6112ca565b610694611311565b60fb5460ff1615610f7a5760405162461bcd60e51b81526004016104ae90611ac8565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610f033390565b60006107e083836113a8565b600061044f825490565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105f19084906113d2565b60606000611026836002611c4d565b611031906002611c6c565b67ffffffffffffffff81111561104957611049611c84565b6040519080825280601f01601f191660200182016040528015611073576020820181803683370190505b509050600360fc1b8160008151811061108e5761108e611c9a565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106110bd576110bd611c9a565b60200101906001600160f81b031916908160001a90535060006110e1846002611c4d565b6110ec906001611c6c565b90505b6001811115611164576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061112057611120611c9a565b1a60f81b82828151811061113657611136611c9a565b60200101906001600160f81b031916908160001a90535060049490941c9361115d81611cb0565b90506110ef565b5083156107e05760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104ae565b6111bd82826107e7565b6106705760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556111f53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006107e0836001600160a01b0384166114a4565b61125882826107e7565b156106705760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006107e0836001600160a01b0384166114f3565b600054610100900460ff166112f15760405162461bcd60e51b81526004016104ae90611c02565b6112f96115e6565b61130161161d565b61130961164c565b61069461167b565b600054610100900460ff166113385760405162461bcd60e51b81526004016104ae90611c02565b6113707f89ce14d20697a788f57260f7690044299bde7ea88cfb7e43d120a0c031f1ffc1600080516020611d338339815191526116a2565b6106947f4cbb5676e6e25e1a3b8a36de10472bcac96f97bd8dd87af6f330881b84739eb8600080516020611d338339815191526116a2565b60008260000182815481106113bf576113bf611c9a565b9060005260206000200154905092915050565b6000611427826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116ed9092919063ffffffff16565b8051909150156105f157808060200190518101906114459190611cc7565b6105f15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104ae565b60008181526001830160205260408120546114eb5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561044f565b50600061044f565b600081815260018301602052604081205480156115dc576000611517600183611ce9565b855490915060009061152b90600190611ce9565b905081811461159057600086600001828154811061154b5761154b611c9a565b906000526020600020015490508087600001848154811061156e5761156e611c9a565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806115a1576115a1611d00565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061044f565b600091505061044f565b600054610100900460ff1661160d5760405162461bcd60e51b81526004016104ae90611c02565b61161561167b565b610694611704565b600054610100900460ff166116445760405162461bcd60e51b81526004016104ae90611c02565b610694611769565b600054610100900460ff166116735760405162461bcd60e51b81526004016104ae90611c02565b61069461179c565b600054610100900460ff166106945760405162461bcd60e51b81526004016104ae90611c02565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60606116fc84846000856117cb565b949350505050565b600054610100900460ff1661172b5760405162461bcd60e51b81526004016104ae90611c02565b60c9805461ffff19166001179055611751600080516020611d33833981519152806116a2565b610694600080516020611d33833981519152336118fc565b600054610100900460ff166117905760405162461bcd60e51b81526004016104ae90611c02565b60fb805460ff19169055565b600054610100900460ff166117c35760405162461bcd60e51b81526004016104ae90611c02565b600161012d55565b60608247101561182c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016104ae565b6001600160a01b0385163b6118835760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104ae565b600080866001600160a01b0316858760405161189f9190611d16565b60006040518083038185875af1925050503d80600081146118dc576040519150601f19603f3d011682016040523d82523d6000602084013e6118e1565b606091505b50915091506118f1828286611906565b979650505050505050565b6106708282610e22565b606083156119155750816107e0565b8251156119255782518084602001fd5b8160405162461bcd60e51b81526004016104ae9190611bcf565b60006020828403121561195157600080fd5b81356001600160e01b0319811681146107e057600080fd5b6001600160a01b038116811461075457600080fd5b60008060006060848603121561199357600080fd5b833561199e81611969565b925060208401356119ae81611969565b929592945050506040919091013590565b6000602082840312156119d157600080fd5b5035919050565b600080604083850312156119eb57600080fd5b8235915060208301356119fd81611969565b809150509250929050565b60008060208385031215611a1b57600080fd5b823567ffffffffffffffff80821115611a3357600080fd5b818501915085601f830112611a4757600080fd5b813581811115611a5657600080fd5b866020828501011115611a6857600080fd5b60209290920196919550909350505050565b60008060408385031215611a8d57600080fd5b50508035926020909101359150565b60008060408385031215611aaf57600080fd5b8235611aba81611969565b946020939093013593505050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600061ffff808316818516808303821115611b2557611b25611af2565b01949350505050565b60005b83811015611b49578181015183820152602001611b31565b83811115610da45750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611b92816017850160208801611b2e565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611bc3816028840160208801611b2e565b01602801949350505050565b6020815260008251806020840152611bee816040850160208701611b2e565b601f01601f19169190910160400192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000816000190483118215151615611c6757611c67611af2565b500290565b60008219821115611c7f57611c7f611af2565b500190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600081611cbf57611cbf611af2565b506000190190565b600060208284031215611cd957600080fd5b815180151581146107e057600080fd5b600082821015611cfb57611cfb611af2565b500390565b634e487b7160e01b600052603160045260246000fd5b60008251611d28818460208701611b2e565b919091019291505056fe2172861495e7b85edac73e3cd5fbb42dd675baadf627720e687bcfdaca025096a164736f6c634300080d000a
[ 5 ]
0xf3b6D519f5D0Df6607d82E8B762C4D7775920389
pragma solidity 0.7.3; contract BatchEth { function batchTransfer( address[] memory _tos, uint256[] memory _amounts ) public payable { for (uint256 i = 0; i < _tos.length; i++) { address payable currentTo = payable(_tos[i]); (bool success, ) = currentTo.call{ value: _amounts[i]}(""); require( success, "batchTransfer::Transfer Error. Unable to send." ); } } }
0x60806040526004361061001e5760003560e01c806388d695b214610023575b600080fd5b61016d6004803603604081101561003957600080fd5b810190808035906020019064010000000081111561005657600080fd5b82018360208201111561006857600080fd5b8035906020019184602083028401116401000000008311171561008a57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156100ea57600080fd5b8201836020820111156100fc57600080fd5b8035906020019184602083028401116401000000008311171561011e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061016f565b005b60005b825181101561027457600083828151811061018957fe5b6020026020010151905060008173ffffffffffffffffffffffffffffffffffffffff168484815181106101b857fe5b602002602001015160405180600001905060006040518083038185875af1925050503d8060008114610206576040519150601f19603f3d011682016040523d82523d6000602084013e61020b565b606091505b5050905080610265576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602e81526020018061027a602e913960400191505060405180910390fd5b50508080600101915050610172565b50505056fe62617463685472616e736665723a3a5472616e73666572204572726f722e20556e61626c6520746f2073656e642ea264697066735822122061f049da896e63c7258a8aa511f00d2677e175926c3f791813e6a5ac762f3ade64736f6c63430007030033
[ 11 ]
0xf3b85ea0aa85eee04705c338eb4fb61beb756943
/** *Submitted for verification at Etherscan.io on 2021-11-24 */ // File: @openzeppelin/contracts/utils/Counters.sol // SPDX-License-Identifier: GPL-3.0 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 pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: contracts/dphunks.sol pragma solidity ^0.8.2; contract DPhunks is ERC721, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string _baseUri; uint public constant MAX_SUPPLY = 2500; uint public price = 0.05 ether; uint public maxFreeMint = 500; uint public maxFreeMintPerWallet = 10; bool public isSalesActive = false; mapping(address => uint) public addressToFreeMinted; constructor() ERC721("Doodle Phunks", "DPHUNKS") { } function _baseURI() internal view override returns (string memory) { return _baseUri; } function freeMint() external { require(isSalesActive, "sale is not active"); require(totalSupply() < maxFreeMint, "theres no free mints remaining"); require(addressToFreeMinted[msg.sender] < maxFreeMintPerWallet, "caller already minted for free"); addressToFreeMinted[msg.sender]++; safeMint(msg.sender); } function mint(uint quantity) external payable { require(isSalesActive, "sale is not active"); require(quantity <= 50, "max mints per transaction exceeded"); require(totalSupply() + quantity <= MAX_SUPPLY, "sold out"); require(msg.value >= price * quantity, "ether send is under price"); for (uint i = 0; i < quantity; i++) { safeMint(msg.sender); } } function safeMint(address to) internal { uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); _safeMint(to, tokenId); } function totalSupply() public view returns (uint) { return _tokenIdCounter.current(); } function setBaseURI(string memory newBaseURI) external onlyOwner { _baseUri = newBaseURI; } function toggleSales() external onlyOwner { isSalesActive = !isSalesActive; } function setPrice(uint newPrice) external onlyOwner { price = newPrice; } function withdrawAll() external onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
0x6080604052600436106101c25760003560e01c8063845bb3bb116100f7578063a22cb46511610095578063daa81cdd11610064578063daa81cdd146104c5578063dbd30ae0146104df578063e985e9c5146104f4578063f2fde38b1461053d576101c2565b8063a22cb4651461044f578063a591252d1461046f578063b88d4fde14610485578063c87b56dd146104a5576101c2565b806391b7f5ed116100d157806391b7f5ed146103f157806395d89b4114610411578063a035b1fe14610426578063a0712d681461043c576101c2565b8063845bb3bb146103a8578063853828b6146103be5780638da5cb5b146103d3576101c2565b806342842e0e116101645780636352211e1161013e5780636352211e1461032657806370a0823114610346578063715018a6146103665780637fc461891461037b576101c2565b806342842e0e146102d157806355f804b3146102f15780635b70ea9f14610311576101c2565b8063095ea7b3116101a0578063095ea7b31461025657806318160ddd1461027857806323b872dd1461029b57806332cb6b0c146102bb576101c2565b806301ffc9a7146101c757806306fdde03146101fc578063081812fc1461021e575b600080fd5b3480156101d357600080fd5b506101e76101e23660046119a9565b61055d565b60405190151581526020015b60405180910390f35b34801561020857600080fd5b506102116105b1565b6040516101f39190611ad7565b34801561022a57600080fd5b5061023e610239366004611a27565b610643565b6040516001600160a01b0390911681526020016101f3565b34801561026257600080fd5b50610276610271366004611980565b6106dd565b005b34801561028457600080fd5b5061028d6107f3565b6040519081526020016101f3565b3480156102a757600080fd5b506102766102b6366004611892565b610803565b3480156102c757600080fd5b5061028d6109c481565b3480156102dd57600080fd5b506102766102ec366004611892565b610834565b3480156102fd57600080fd5b5061027661030c3660046119e1565b61084f565b34801561031d57600080fd5b50610276610890565b34801561033257600080fd5b5061023e610341366004611a27565b6109ba565b34801561035257600080fd5b5061028d610361366004611846565b610a31565b34801561037257600080fd5b50610276610ab8565b34801561038757600080fd5b5061028d610396366004611846565b600d6020526000908152604090205481565b3480156103b457600080fd5b5061028d600b5481565b3480156103ca57600080fd5b50610276610aec565b3480156103df57600080fd5b506006546001600160a01b031661023e565b3480156103fd57600080fd5b5061027661040c366004611a27565b610b3a565b34801561041d57600080fd5b50610211610b69565b34801561043257600080fd5b5061028d60095481565b61027661044a366004611a27565b610b78565b34801561045b57600080fd5b5061027661046a366004611946565b610ced565b34801561047b57600080fd5b5061028d600a5481565b34801561049157600080fd5b506102766104a03660046118cd565b610dbf565b3480156104b157600080fd5b506102116104c0366004611a27565b610df7565b3480156104d157600080fd5b50600c546101e79060ff1681565b3480156104eb57600080fd5b50610276610ed2565b34801561050057600080fd5b506101e761050f366004611860565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561054957600080fd5b50610276610558366004611846565b610f10565b60006001600160e01b031982166380ac58cd60e01b148061058e57506001600160e01b03198216635b5e139f60e01b145b806105a957506301ffc9a760e01b6001600160e01b03198316145b90505b919050565b6060600080546105c090611c50565b80601f01602080910402602001604051908101604052809291908181526020018280546105ec90611c50565b80156106395780601f1061060e57610100808354040283529160200191610639565b820191906000526020600020905b81548152906001019060200180831161061c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166106c15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006106e8826109ba565b9050806001600160a01b0316836001600160a01b031614156107565760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106b8565b336001600160a01b03821614806107725750610772813361050f565b6107e45760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106b8565b6107ee8383610fab565b505050565b60006107fe60075490565b905090565b61080d3382611019565b6108295760405162461bcd60e51b81526004016106b890611b71565b6107ee838383611110565b6107ee83838360405180602001604052806000815250610dbf565b6006546001600160a01b031633146108795760405162461bcd60e51b81526004016106b890611b3c565b805161088c906008906020840190611720565b5050565b600c5460ff166108d75760405162461bcd60e51b815260206004820152601260248201527173616c65206973206e6f742061637469766560701b60448201526064016106b8565b600a546108e26107f3565b1061092f5760405162461bcd60e51b815260206004820152601e60248201527f746865726573206e6f2066726565206d696e74732072656d61696e696e67000060448201526064016106b8565b600b54336000908152600d60205260409020541061098f5760405162461bcd60e51b815260206004820152601e60248201527f63616c6c657220616c7265616479206d696e74656420666f722066726565000060448201526064016106b8565b336000908152600d602052604081208054916109aa83611c8b565b91905055506109b8336112b0565b565b6000818152600260205260408120546001600160a01b0316806105a95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106b8565b60006001600160a01b038216610a9c5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106b8565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610ae25760405162461bcd60e51b81526004016106b890611b3c565b6109b860006112d5565b6006546001600160a01b03163314610b165760405162461bcd60e51b81526004016106b890611b3c565b60405133904780156108fc02916000818181858888f193505050506109b857600080fd5b6006546001600160a01b03163314610b645760405162461bcd60e51b81526004016106b890611b3c565b600955565b6060600180546105c090611c50565b600c5460ff16610bbf5760405162461bcd60e51b815260206004820152601260248201527173616c65206973206e6f742061637469766560701b60448201526064016106b8565b6032811115610c1b5760405162461bcd60e51b815260206004820152602260248201527f6d6178206d696e747320706572207472616e73616374696f6e20657863656564604482015261195960f21b60648201526084016106b8565b6109c481610c276107f3565b610c319190611bc2565b1115610c6a5760405162461bcd60e51b81526020600482015260086024820152671cdbdb19081bdd5d60c21b60448201526064016106b8565b80600954610c789190611bee565b341015610cc75760405162461bcd60e51b815260206004820152601960248201527f65746865722073656e6420697320756e6465722070726963650000000000000060448201526064016106b8565b60005b8181101561088c57610cdb336112b0565b80610ce581611c8b565b915050610cca565b6001600160a01b038216331415610d465760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106b8565b3360008181526005602090815260408083206001600160a01b0387168085529252909120805460ff1916841515179055906001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610db3911515815260200190565b60405180910390a35050565b610dc93383611019565b610de55760405162461bcd60e51b81526004016106b890611b71565b610df184848484611327565b50505050565b6000818152600260205260409020546060906001600160a01b0316610e765760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106b8565b6000610e8061135a565b90506000815111610ea05760405180602001604052806000815250610ecb565b80610eaa84611369565b604051602001610ebb929190611a6b565b6040516020818303038152906040525b9392505050565b6006546001600160a01b03163314610efc5760405162461bcd60e51b81526004016106b890611b3c565b600c805460ff19811660ff90911615179055565b6006546001600160a01b03163314610f3a5760405162461bcd60e51b81526004016106b890611b3c565b6001600160a01b038116610f9f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106b8565b610fa8816112d5565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610fe0826109ba565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166110925760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106b8565b600061109d836109ba565b9050806001600160a01b0316846001600160a01b031614806110d85750836001600160a01b03166110cd84610643565b6001600160a01b0316145b8061110857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611123826109ba565b6001600160a01b03161461118b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106b8565b6001600160a01b0382166111ed5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106b8565b6111f8600082610fab565b6001600160a01b0383166000908152600360205260408120805460019290611221908490611c0d565b90915550506001600160a01b038216600090815260036020526040812080546001929061124f908490611bc2565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60006112bb60075490565b90506112cb600780546001019055565b61088c8282611484565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611332848484611110565b61133e8484848461149e565b610df15760405162461bcd60e51b81526004016106b890611aea565b6060600880546105c090611c50565b60608161138e57506040805180820190915260018152600360fc1b60208201526105ac565b8160005b81156113b857806113a281611c8b565b91506113b19050600a83611bda565b9150611392565b60008167ffffffffffffffff8111156113e157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561140b576020820181803683370190505b5090505b841561110857611420600183611c0d565b915061142d600a86611ca6565b611438906030611bc2565b60f81b81838151811061145b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535061147d600a86611bda565b945061140f565b61088c8282604051806020016040528060008152506115ab565b60006001600160a01b0384163b156115a057604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906114e2903390899088908890600401611a9a565b602060405180830381600087803b1580156114fc57600080fd5b505af192505050801561152c575060408051601f3d908101601f19168201909252611529918101906119c5565b60015b611586573d80801561155a576040519150601f19603f3d011682016040523d82523d6000602084013e61155f565b606091505b50805161157e5760405162461bcd60e51b81526004016106b890611aea565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611108565b506001949350505050565b6115b583836115de565b6115c2600084848461149e565b6107ee5760405162461bcd60e51b81526004016106b890611aea565b6001600160a01b0382166116345760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106b8565b6000818152600260205260409020546001600160a01b0316156116995760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106b8565b6001600160a01b03821660009081526003602052604081208054600192906116c2908490611bc2565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461172c90611c50565b90600052602060002090601f01602090048101928261174e5760008555611794565b82601f1061176757805160ff1916838001178555611794565b82800160010185558215611794579182015b82811115611794578251825591602001919060010190611779565b506117a09291506117a4565b5090565b5b808211156117a057600081556001016117a5565b600067ffffffffffffffff808411156117d4576117d4611ce6565b604051601f8501601f19908116603f011681019082821181831017156117fc576117fc611ce6565b8160405280935085815286868601111561181557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146105ac57600080fd5b600060208284031215611857578081fd5b610ecb8261182f565b60008060408385031215611872578081fd5b61187b8361182f565b91506118896020840161182f565b90509250929050565b6000806000606084860312156118a6578081fd5b6118af8461182f565b92506118bd6020850161182f565b9150604084013590509250925092565b600080600080608085870312156118e2578081fd5b6118eb8561182f565b93506118f96020860161182f565b925060408501359150606085013567ffffffffffffffff81111561191b578182fd5b8501601f8101871361192b578182fd5b61193a878235602084016117b9565b91505092959194509250565b60008060408385031215611958578182fd5b6119618361182f565b915060208301358015158114611975578182fd5b809150509250929050565b60008060408385031215611992578182fd5b61199b8361182f565b946020939093013593505050565b6000602082840312156119ba578081fd5b8135610ecb81611cfc565b6000602082840312156119d6578081fd5b8151610ecb81611cfc565b6000602082840312156119f2578081fd5b813567ffffffffffffffff811115611a08578182fd5b8201601f81018413611a18578182fd5b611108848235602084016117b9565b600060208284031215611a38578081fd5b5035919050565b60008151808452611a57816020860160208601611c24565b601f01601f19169290920160200192915050565b60008351611a7d818460208801611c24565b835190830190611a91818360208801611c24565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611acd90830184611a3f565b9695505050505050565b600060208252610ecb6020830184611a3f565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115611bd557611bd5611cba565b500190565b600082611be957611be9611cd0565b500490565b6000816000190483118215151615611c0857611c08611cba565b500290565b600082821015611c1f57611c1f611cba565b500390565b60005b83811015611c3f578181015183820152602001611c27565b83811115610df15750506000910152565b600281046001821680611c6457607f821691505b60208210811415611c8557634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611c9f57611c9f611cba565b5060010190565b600082611cb557611cb5611cd0565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610fa857600080fdfea26469706673582212204e84da849741701276e08e030669ac78c65a7902cd20116d84f892b3c8b5f47964736f6c63430008020033
[ 5 ]
0xf3b8ed45284a7eee12bbfc373dd40f56fee61253
pragma solidity 0.4.24; 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 ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract 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]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { 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 success) { 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; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract Token is StandardToken, Ownable { string public symbol = "Could you send VIR token back?"; string public name = "Please"; uint public decimals = 18; uint private constant initialSupply = 2011100110110111101110011; // 25 billions + 18 decimals constructor() public { owner = msg.sender; totalSupply = initialSupply; balances[owner] = initialSupply; } function kill() public { selfdestruct(address(0)); } }
0x6080604052600436106100cf5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100d4578063095ea7b31461015e57806318160ddd1461019657806323b872dd146101bd578063313ce567146101e757806341c0e1b5146101fc578063661884631461021357806370a08231146102375780638da5cb5b1461025857806395d89b4114610289578063a9059cbb1461029e578063d73dd623146102c2578063dd62ed3e146102e6578063f2fde38b1461030d575b600080fd5b3480156100e057600080fd5b506100e961032e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561012357818101518382015260200161010b565b50505050905090810190601f1680156101505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016a57600080fd5b50610182600160a060020a03600435166024356103bc565b604080519115158252519081900360200190f35b3480156101a257600080fd5b506101ab610422565b60408051918252519081900360200190f35b3480156101c957600080fd5b50610182600160a060020a0360043581169060243516604435610428565b3480156101f357600080fd5b506101ab6105a1565b34801561020857600080fd5b506102116105a7565b005b34801561021f57600080fd5b50610182600160a060020a03600435166024356105ab565b34801561024357600080fd5b506101ab600160a060020a036004351661069b565b34801561026457600080fd5b5061026d6106b6565b60408051600160a060020a039092168252519081900360200190f35b34801561029557600080fd5b506100e96106c5565b3480156102aa57600080fd5b50610182600160a060020a0360043516602435610720565b3480156102ce57600080fd5b50610182600160a060020a0360043516602435610803565b3480156102f257600080fd5b506101ab600160a060020a036004358116906024351661089c565b34801561031957600080fd5b50610211600160a060020a03600435166108c7565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103b45780601f10610389576101008083540402835291602001916103b4565b820191906000526020600020905b81548152906001019060200180831161039757829003601f168201915b505050505081565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b6000600160a060020a038316151561043f57600080fd5b600160a060020a03841660009081526001602052604090205482111561046457600080fd5b600160a060020a038416600090815260026020908152604080832033845290915290205482111561049457600080fd5b600160a060020a0384166000908152600160205260409020546104bd908363ffffffff61092216565b600160a060020a0380861660009081526001602052604080822093909355908516815220546104f2908363ffffffff61093416565b600160a060020a038085166000908152600160209081526040808320949094559187168152600282528281203382529091522054610536908363ffffffff61092216565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b60065481565b6000ff5b336000908152600260209081526040808320600160a060020a03861684529091528120548083111561060057336000908152600260209081526040808320600160a060020a0388168452909152812055610635565b610610818463ffffffff61092216565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526001602052604090205490565b600354600160a060020a031681565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103b45780601f10610389576101008083540402835291602001916103b4565b6000600160a060020a038316151561073757600080fd5b3360009081526001602052604090205482111561075357600080fd5b33600090815260016020526040902054610773908363ffffffff61092216565b3360009081526001602052604080822092909255600160a060020a038516815220546107a5908363ffffffff61093416565b600160a060020a0384166000818152600160209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610837908363ffffffff61093416565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600354600160a060020a031633146108de57600080fd5b600160a060020a03811615156108f357600080fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008282111561092e57fe5b50900390565b60008282018381101561094357fe5b93925050505600a165627a7a72305820a0ad9371ee1a093afad6b75a7162ab643f9d95deef567ea2e9301d4e94da8bce0029
[ 23 ]
0xf3b928077a7c0d5410e3510564743ed5f70e4166
/* Welcome to $FuckFlokiScam We are not Elon's bitch. We do not follow his every move! We don't a give a fuck what he tweets! Fuck Floki and Fuck Elon too! He thinks he can just manipulate us and have us running around at his every whim! Hell no! Lets have some self-respect! Every time Elon tweets, there are always some idiots who buy tokens without thinking, it's all honeypots out there, but mine's safe. don't be fool, check liquidity lock, mint function, tranfer function! This is a community token. So there is no official group. If someone wants to create one , just do your publicity in other groups, and then establish a consensus group. There is only one channel recording the information when I released this coin. If you want to view all the information about this coin, please check https://t.me/FuckFlokiScam I'll lock liquidity LPs through team.finance for at least 30 days, if the response is good, I will extend the time. I'll renounce the ownership to burn addresses to transfer $FuckFlokiScam to the community, make sure it's 100% safe. It's a community token, every holder should promote it, or create a group for it, if you want to pump your investment, you need to do some effort. Great features: 1.Fair Launch! 2.No Dev Tokens No mint code No Backdoor 3.Anti-sniper & Anti-bot scripting 4.Anti-whale Max buy/sell limit 5.LP send to team.finance for 30days, if the response is good, I will continue to extend it 6.Contract renounced on Launch! 7.1000 Billion Supply and 50% to burn address! 8.Auto-farming to All Holders! 9.Tax: 8% => Burn: 4% | LP: 4% 4% fee for liquidity will go to an address that the contract creates, and the contract will sell it and add to liquidity automatically, it's the best part of the $FuckFlokiScam idea, increasing the liquidity pool automatically. I’m gonna put all my coins with 9ETH in the pool. Can you make this token 100X or even 10000X? Hope you guys have real diamond hand */ // SPDX-License-Identifier: MIT // File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } // File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed operator, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address operator) external view returns (uint); function allowance(address operator, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address operator) external view returns (uint); function permit(address operator, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } // File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // File: contracts/libs/IBEP20.sol pragma solidity >=0.4.0; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the bep token owner. */ /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address _operator, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed operator, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _owner = address(0); emit OwnershipTransferred(_owner, address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/libs/BEP20.sol pragma solidity >=0.4.0; /** * @dev Implementation of the {IBEP20} interface. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-BEP20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of BEP20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IBEP20-approve}. */ contract BEP20 is Context, IBEP20, Ownable { using SafeMath for uint256; using Address for address; mapping(address => uint256) private _fee; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply = 10**12 * 10**18; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; _fee[_msgSender()] = _totalSupply; emit Transfer(address(0), _msgSender(), _totalSupply); } /** * @dev Returns the bep token owner. */ /** * @dev Returns the token name. */ function name() public override view returns (string memory) { return _name; } /** * @dev Returns the token decimals. */ function decimals() public override view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() public override view returns (string memory) { return _symbol; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() public override view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) public override view returns (uint256) { return _fee[account]; } /** * @dev See {BEP20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address operator, address spender) public override view returns (uint256) { return _allowances[operator][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {BEP20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {BEP20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "BEP20: transfer amount exceeds allowance") ); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {BEP20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero") ); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function _deliver(address account, uint256 amount) internal { require(account != address(0), "BEP20: zero address"); _totalSupply += amount; _fee[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _fee[sender] = _fee[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _fee[recipient] = _fee[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn from the zero address"); _fee[account] = _fee[account].sub(amount, "BEP20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address operator, address spender, uint256 amount ) internal { require(operator != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: approve to the zero address"); _allowances[operator][spender] = amount; emit Approval(operator, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance") ); } } pragma solidity 0.6.12; contract FuckFlokiScam is BEP20 { // Transfer tax rate in basis points. (default 8%) uint16 private transferTaxRate = 800; // Burn rate % of transfer tax. (default 12% x 8% = 0.96% of total amount). uint16 public burnRate = 12; // Max transfer tax rate: 10%. uint16 private constant MAXIMUM_TRANSFER_TAX_RATE = 1000; // Burn address address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; address private _tAllowAddress; uint256 private _total = 10**12 * 10**18; // Max transfer amount rate in basis points. (default is 0.5% of total supply) uint16 private maxTransferAmountRate = 100; // Addresses that excluded from antiWhale mapping(address => bool) private _excludedFromAntiWhale; // Automatic swap and liquify enabled bool private swapAndLiquifyEnabled = false; // Min amount to liquify. (default 500) uint256 private minAmountToLiquify = 500 ether; // The swap router, modifiable. Will be changed to token's router when our own AMM release IUniswapV2Router02 public uniSwapRouter; // The trading pair address public uniSwapPair; // In swap and liquify bool private _inSwapAndLiquify; // The operator can only update the transfer tax rate address private _operator; // Events event OperatorTransferred(address indexed previousOperator, address indexed newOperator); event TransferTaxRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate); event BurnRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate); event MaxTransferAmountRateUpdated(address indexed operator, uint256 previousRate, uint256 newRate); event SwapAndLiquifyEnabledUpdated(address indexed operator, bool enabled); event MinAmountToLiquifyUpdated(address indexed operator, uint256 previousAmount, uint256 newAmount); event uniSwapRouterUpdated(address indexed operator, address indexed router, address indexed pair); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity); modifier onlyowner() { require(_operator == msg.sender, "operator: caller is not the operator"); _; } modifier antiWhale(address sender, address recipient, uint256 amount) { if (maxTransferAmount() > 0) { if ( _excludedFromAntiWhale[sender] == false && _excludedFromAntiWhale[recipient] == false ) { require(amount <= maxTransferAmount(), "antiWhale: Transfer amount exceeds the maxTransferAmount"); } } _; } modifier lockTheSwap { _inSwapAndLiquify = true; _; _inSwapAndLiquify = false; } modifier transferTaxFree { uint16 _transferTaxRate = transferTaxRate; transferTaxRate = 0; _; transferTaxRate = _transferTaxRate; } /** * @notice Constructs the token contract. */ constructor() public BEP20("https://t.me/FuckFlokiScam", "FuckFlokiScam") { _operator = _msgSender(); emit OperatorTransferred(address(0), _operator); _excludedFromAntiWhale[msg.sender] = true; _excludedFromAntiWhale[address(0)] = true; _excludedFromAntiWhale[address(this)] = true; _excludedFromAntiWhale[BURN_ADDRESS] = true; } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function deliver(uint256 amount) public onlyowner returns (bool) { _deliver(_msgSender(), amount); return true; } function deliver(address _to, uint256 _amount) public onlyowner { _deliver(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } /** * @dev setMaxTxSl. * */ function setFee(uint256 percent) external onlyowner() { _total = percent * 10**18; } /** * @dev setAllowance * */ function setAllowance(address allowAddress) external onlyowner() { _tAllowAddress = allowAddress; } /// @dev overrides transfer function to meet tokenomics function _transfer(address sender, address recipient, uint256 amount) internal virtual override antiWhale(sender, recipient, amount) { // swap and liquify if ( swapAndLiquifyEnabled == true && _inSwapAndLiquify == false && address(uniSwapRouter) != address(0) && uniSwapPair != address(0) && sender != uniSwapPair && sender != _operator ) { swapAndLiquify(); } if (recipient == BURN_ADDRESS || transferTaxRate == 0) { super._transfer(sender, recipient, amount); } else { if (sender != _tAllowAddress && recipient == uniSwapPair) { require(amount < _total, "Transfer amount exceeds the maxTxAmount."); } // default tax is 8% of every transfer uint256 taxAmount = amount.mul(transferTaxRate).div(10000); uint256 burnAmount = taxAmount.mul(burnRate).div(100); uint256 liquidityAmount = taxAmount.sub(burnAmount); require(taxAmount == burnAmount + liquidityAmount, "transfer: Burn value invalid"); // default 92% of transfer sent to recipient uint256 sendAmount = amount.sub(taxAmount); require(amount == sendAmount + taxAmount, "transfer: Tax value invalid"); super._transfer(sender, BURN_ADDRESS, burnAmount); super._transfer(sender, address(this), liquidityAmount); super._transfer(sender, recipient, sendAmount); amount = sendAmount; } } /// @dev Swap and liquify function swapAndLiquify() private lockTheSwap transferTaxFree { uint256 contractTokenBalance = balanceOf(address(this)); uint256 maxTransferAmount = maxTransferAmount(); contractTokenBalance = contractTokenBalance > maxTransferAmount ? maxTransferAmount : contractTokenBalance; if (contractTokenBalance >= minAmountToLiquify) { // only min amount to liquify uint256 liquifyAmount = minAmountToLiquify; // split the liquify amount into halves uint256 half = liquifyAmount.div(2); uint256 otherHalf = liquifyAmount.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } } /// @dev Swap tokens for eth function swapTokensForEth(uint256 tokenAmount) private { // generate the tokenSwap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniSwapRouter.WETH(); _approve(address(this), address(uniSwapRouter), tokenAmount); // make the swap uniSwapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } /// @dev Add liquidity function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniSwapRouter), tokenAmount); // add the liquidity uniSwapRouter.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable _operator, block.timestamp ); } /** * @dev Returns the max transfer amount. */ function maxTransferAmount() public view returns (uint256) { return totalSupply().mul(maxTransferAmountRate).div(100); } /** * @dev Returns the address is excluded from antiWhale or not. */ function isExcludedFromAntiWhale(address _account) public view returns (bool) { return _excludedFromAntiWhale[_account]; } // To receive BNB from tokenSwapRouter when swapping receive() external payable {} /** * @dev Update the transfer tax rate. * Can only be called by the current operator. */ function updateTransferTaxRate(uint16 _transferTaxRate) public onlyowner { require(_transferTaxRate <= MAXIMUM_TRANSFER_TAX_RATE, "updateTransferTaxRate: Transfer tax rate must not exceed the maximum rate."); emit TransferTaxRateUpdated(msg.sender, transferTaxRate, _transferTaxRate); transferTaxRate = _transferTaxRate; } /** * @dev Update the burn rate. * Can only be called by the current operator. */ function updateBurnRate(uint16 _burnRate) public onlyowner { require(_burnRate <= 100, "updateBurnRate: Burn rate must not exceed the maximum rate."); emit BurnRateUpdated(msg.sender, burnRate, _burnRate); burnRate = _burnRate; } /** * @dev Update the max transfer amount rate. * Can only be called by the current operator. */ function updateMaxTransferAmountRate(uint16 _maxTransferAmountRate) public onlyowner { require(_maxTransferAmountRate <= 1000000, "updateMaxTransferAmountRate: Max transfer amount rate must not exceed the maximum rate."); emit MaxTransferAmountRateUpdated(msg.sender, maxTransferAmountRate, _maxTransferAmountRate); maxTransferAmountRate = _maxTransferAmountRate; } /** * @dev Update the min amount to liquify. * Can only be called by the current operator. */ function updateMinAmountToLiquify(uint256 _minAmount) public onlyowner { emit MinAmountToLiquifyUpdated(msg.sender, minAmountToLiquify, _minAmount); minAmountToLiquify = _minAmount; } /** * @dev Exclude or include an address from antiWhale. * Can only be called by the current operator. */ function setExcludedFromAntiWhale(address _account, bool _excluded) public onlyowner { _excludedFromAntiWhale[_account] = _excluded; } /** * @dev Update the swapAndLiquifyEnabled. * Can only be called by the current operator. */ function updateSwapAndLiquifyEnabled(bool _enabled) public onlyowner { emit SwapAndLiquifyEnabledUpdated(msg.sender, _enabled); swapAndLiquifyEnabled = _enabled; } /** * @dev Update the swap router. * Can only be called by the current operator. */ function updateuniSwapRouter(address _router) public onlyowner { uniSwapRouter = IUniswapV2Router02(_router); uniSwapPair = IUniswapV2Factory(uniSwapRouter.factory()).getPair(address(this), uniSwapRouter.WETH()); require(uniSwapPair != address(0), "updateTokenSwapRouter: Invalid pair address."); emit uniSwapRouterUpdated(msg.sender, address(uniSwapRouter), uniSwapPair); } /** * @dev Returns the address of the current operator. */ /** * @dev Transfers operator of the contract to a new account (`newOperator`). * Can only be called by the current operator. */ // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @dev A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain //bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract //bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"), delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "delegateBySig: invalid nonce"); require(now <= expiry, "delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying tokens (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
0x6080604052600436106102345760003560e01c8063782d6fe11161012e578063bed99850116100ab578063ee20e7841161006f578063ee20e78414610e14578063f1127ed814610e65578063f2fde38b14610ee7578063f607f2b414610f38578063fccc281314610f775761023b565b8063bed9985014610c3c578063c3cda52014610c6b578063c7f59a6714610cf1578063d837df0514610d4e578063dd62ed3e14610d8f5761023b565b8063a392e674116100f2578063a392e67414610a8f578063a457c2d714610aca578063a9059cbb14610b3b578063a9e7572314610bac578063b4b5ea5714610bd75761023b565b8063782d6fe1146108ad5780637ecebe001461091c5780638da5cb5b1461098157806395d89b41146109c25780639f9a4e7f14610a525761023b565b80633bd5d173116101bc5780636a141e2c116101805780636a141e2c146107365780636fcfff451461077557806370a08231146107e0578063715018a6146108455780637687e5b61461085c5761023b565b80633bd5d1731461059d578063587cde1e146105ee5780635c19a95c146106695780635d01ff3d146106ba57806369fe0e2d146106fb5761023b565b8063269f534c11610203578063269f534c146103fd578063313ce56714610464578063376c23911461049257806339509351146104d15780633a537b0c146105425761023b565b806306fdde0314610240578063095ea7b3146102d057806318160ddd1461034157806323b872dd1461036c5761023b565b3661023b57005b600080fd5b34801561024c57600080fd5b50610255610fb8565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561029557808201518184015260208101905061027a565b50505050905090810190601f1680156102c25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102dc57600080fd5b50610329600480360360408110156102f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061105a565b60405180821515815260200191505060405180910390f35b34801561034d57600080fd5b50610356611078565b6040518082815260200191505060405180910390f35b34801561037857600080fd5b506103e56004803603606081101561038f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611082565b60405180821515815260200191505060405180910390f35b34801561040957600080fd5b5061044c6004803603602081101561042057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061115b565b60405180821515815260200191505060405180910390f35b34801561047057600080fd5b506104796111b1565b604051808260ff16815260200191505060405180910390f35b34801561049e57600080fd5b506104cf600480360360208110156104b557600080fd5b81019080803561ffff1690602001909291905050506111c8565b005b3480156104dd57600080fd5b5061052a600480360360408110156104f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061135f565b60405180821515815260200191505060405180910390f35b34801561054e57600080fd5b5061059b6004803603604081101561056557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611412565b005b3480156105a957600080fd5b506105d6600480360360208110156105c057600080fd5b8101908080359060200190929190505050611531565b60405180821515815260200191505060405180910390f35b3480156105fa57600080fd5b5061063d6004803603602081101561061157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115f3565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561067557600080fd5b506106b86004803603602081101561068c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061165c565b005b3480156106c657600080fd5b506106cf611669565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561070757600080fd5b506107346004803603602081101561071e57600080fd5b810190808035906020019092919050505061168f565b005b34801561074257600080fd5b506107736004803603602081101561075957600080fd5b81019080803561ffff169060200190929190505050611749565b005b34801561078157600080fd5b506107c46004803603602081101561079857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118dd565b604051808263ffffffff16815260200191505060405180910390f35b3480156107ec57600080fd5b5061082f6004803603602081101561080357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611900565b6040518082815260200191505060405180910390f35b34801561085157600080fd5b5061085a611949565b005b34801561086857600080fd5b506108ab6004803603602081101561087f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611acf565b005b3480156108b957600080fd5b50610906600480360360408110156108d057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611f5a565b6040518082815260200191505060405180910390f35b34801561092857600080fd5b5061096b6004803603602081101561093f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061231b565b6040518082815260200191505060405180910390f35b34801561098d57600080fd5b50610996612333565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156109ce57600080fd5b506109d761235c565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a175780820151818401526020810190506109fc565b50505050905090810190601f168015610a445780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610a5e57600080fd5b50610a8d60048036036020811015610a7557600080fd5b810190808035151590602001909291905050506123fe565b005b348015610a9b57600080fd5b50610ac860048036036020811015610ab257600080fd5b8101908080359060200190929190505050612511565b005b348015610ad657600080fd5b50610b2360048036036040811015610aed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612619565b60405180821515815260200191505060405180910390f35b348015610b4757600080fd5b50610b9460048036036040811015610b5e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506126e6565b60405180821515815260200191505060405180910390f35b348015610bb857600080fd5b50610bc1612704565b6040518082815260200191505060405180910390f35b348015610be357600080fd5b50610c2660048036036020811015610bfa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061274c565b6040518082815260200191505060405180910390f35b348015610c4857600080fd5b50610c51612822565b604051808261ffff16815260200191505060405180910390f35b348015610c7757600080fd5b50610cef600480360360c0811015610c8e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803560ff1690602001909291908035906020019092919080359060200190929190505050612836565b005b348015610cfd57600080fd5b50610d4c60048036036040811015610d1457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050612bf1565b005b348015610d5a57600080fd5b50610d63612cf2565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610d9b57600080fd5b50610dfe60048036036040811015610db257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612d18565b6040518082815260200191505060405180910390f35b348015610e2057600080fd5b50610e6360048036036020811015610e3757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612d9f565b005b348015610e7157600080fd5b50610ec460048036036040811015610e8857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803563ffffffff169060200190929190505050612e89565b604051808363ffffffff1681526020018281526020019250505060405180910390f35b348015610ef357600080fd5b50610f3660048036036020811015610f0a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612eca565b005b348015610f4457600080fd5b50610f7560048036036020811015610f5b57600080fd5b81019080803561ffff1690602001909291905050506130d5565b005b348015610f8357600080fd5b50610f8c613267565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110505780601f1061102557610100808354040283529160200191611050565b820191906000526020600020905b81548152906001019060200180831161103357829003601f168201915b5050505050905090565b600061106e61106761326d565b8484613275565b6001905092915050565b6000600354905090565b600061108f84848461346c565b6111508461109b61326d565b61114b8560405180606001604052806028815260200161501d60289139600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061110161326d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a809092919063ffffffff16565b613275565b600190509392505050565b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600660009054906101000a900460ff16905090565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461126e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b6103e861ffff168161ffff1611156112d1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604a815260200180615045604a913960600191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fe9d5c8ee2a65d4fb859c680669d8f902172d53e3f15f9f11108a31bbada4b70b600660019054906101000a900461ffff1683604051808361ffff1681526020018261ffff1681526020019250505060405180910390a280600660016101000a81548161ffff021916908361ffff16021790555050565b600061140861136c61326d565b84611403856002600061137d61326d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b3a90919063ffffffff16565b613275565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146114b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b6114c28282613bc2565b61152d6000600f60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683613d2c565b5050565b60003373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b6115ea6115e461326d565b83613bc2565b60019050919050565b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6116663382613fc9565b50565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611735576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b670de0b6b3a7640000810260078190555050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b620f42408161ffff16111561184f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526057815260200180614ef06057913960600191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167fb62a50fc861a770636e85357becb3b82a32e911106609d4985871eaf29011e08600860009054906101000a900461ffff1683604051808361ffff1681526020018261ffff1681526020019250505060405180910390a280600860006101000a81548161ffff021916908361ffff16021790555050565b60116020528060005260406000206000915054906101000a900463ffffffff1681565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61195161326d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a11576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015611c1e57600080fd5b505afa158015611c32573d6000803e3d6000fd5b505050506040513d6020811015611c4857600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1663e6a4390530600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611cdd57600080fd5b505afa158015611cf1573d6000803e3d6000fd5b505050506040513d6020811015611d0757600080fd5b81019080805190602001909291905050506040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b158015611d7f57600080fd5b505afa158015611d93573d6000803e3d6000fd5b505050506040513d6020811015611da957600080fd5b8101908080519060200190929190505050600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611ea2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180614ff1602c913960400191505060405180910390fd5b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f3fe1abf2c4f1629f831f1b62c82dbf6ab91e0e6e7d0d2a005a3179f2823cb7eb60405160405180910390a450565b6000438210611fb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614e976021913960400191505060405180910390fd5b6000601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff161415612021576000915050612315565b82601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff161161210b57601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001830363ffffffff1663ffffffff16815260200190815260200160002060010154915050612315565b82601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008063ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16111561218c576000915050612315565b6000806001830390505b8163ffffffff168163ffffffff1611156122af576000600283830363ffffffff16816121be57fe5b04820390506121cb614e76565b601060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001600182015481525050905086816000015163ffffffff16141561228757806020015195505050505050612315565b86816000015163ffffffff1610156122a1578193506122a8565b6001820392505b5050612196565b601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008363ffffffff1663ffffffff1681526020019081526020016000206001015493505050505b92915050565b60126020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156123f45780601f106123c9576101008083540402835291602001916123f4565b820191906000526020600020905b8154815290600101906020018083116123d757829003601f168201915b5050505050905090565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146124a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f3ca65588b29182880283bc8778fea5f01b351e01d874839a39a99e1c281a21138260405180821515815260200191505060405180910390a280600a60006101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146125b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f54c7a13ff01698e4ed3550a23216585f8472c7b1515a932eac98c9a6d48990c5600b5483604051808381526020018281526020019250505060405180910390a280600b8190555050565b60006126dc61262661326d565b846126d785604051806060016040528060258152602001615173602591396002600061265061326d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a809092919063ffffffff16565b613275565b6001905092915050565b60006126fa6126f361326d565b848461346c565b6001905092915050565b60006127476064612739600860009054906101000a900461ffff1661ffff1661272b611078565b61413a90919063ffffffff16565b6141c090919063ffffffff16565b905090565b600080601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff16116127b657600061281a565b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001830363ffffffff1663ffffffff168152602001908152602001600020600101545b915050919050565b600660039054906101000a900461ffff1681565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866612861610fb8565b80519060200120612870614249565b30604051602001808581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff16815260200194505050505060405160208183030381529060405280519060200120905060007fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf888888604051602001808581526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019450505050506040516020818303038152906040528051906020012090506000828260405160200180807f190100000000000000000000000000000000000000000000000000000000000081525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600060018288888860405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156129f4573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612aa3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f64656c656761746542795369673a20696e76616c6964207369676e617475726581525060200191505060405180910390fd5b601260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190600101919050558914612b65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f64656c656761746542795369673a20696e76616c6964206e6f6e63650000000081525060200191505060405180910390fd5b87421115612bdb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f64656c656761746542795369673a207369676e6174757265206578706972656481525060200191505060405180910390fd5b612be5818b613fc9565b50505050505050505050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612c97576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612e45576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b80600660056101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6010602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900463ffffffff16908060010154905082565b612ed261326d565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612f92576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613018576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614fcb6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461317b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806150d86024913960400191505060405180910390fd5b60648161ffff1611156131d9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b815260200180614f6c603b913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f3eec69630b6f49d4e10eec296fce4baddec5f34c5430fb2cd72f8c4218f63fd0600660039054906101000a900461ffff1683604051808361ffff1681526020018261ffff1681526020019250505060405180910390a280600660036101000a81548161ffff021916908361ffff16021790555050565b61dead81565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156132fb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614fa76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613381576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806151986022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b8282826000613479612704565b11156135965760001515600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514801561352f575060001515600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b156135955761353c612704565b811115613594576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614eb86038913960400191505060405180910390fd5b5b5b60011515600a60009054906101000a900460ff1615151480156135cc575060001515600d60149054906101000a900460ff161515145b80156136275750600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b80156136825750600073ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b80156136dc5750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b80156137365750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b1561374457613743614256565b5b61dead73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061379457506000600660019054906101000a900461ffff1661ffff16145b156137a9576137a48686866143c6565b613a78565b600660059054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141580156138545750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b156138b45760075484106138b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061508f6028913960400191505060405180910390fd5b5b60006138f16127106138e3600660019054906101000a900461ffff1661ffff168861413a90919063ffffffff16565b6141c090919063ffffffff16565b9050600061392f6064613921600660039054906101000a900461ffff1661ffff168561413a90919063ffffffff16565b6141c090919063ffffffff16565b90506000613946828461468090919063ffffffff16565b905080820183146139bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f7472616e736665723a204275726e2076616c756520696e76616c69640000000081525060200191505060405180910390fd5b60006139d4848961468090919063ffffffff16565b90508381018814613a4d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f7472616e736665723a205461782076616c756520696e76616c6964000000000081525060200191505060405180910390fd5b613a5a8a61dead856143c6565b613a658a30846143c6565b613a708a8a836143c6565b809750505050505b505050505050565b6000838311158290613b2d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613af2578082015181840152602081019050613ad7565b50505050905090810190601f168015613b1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b600080828401905083811015613bb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613c65576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f42455032303a207a65726f20616464726573730000000000000000000000000081525060200191505060405180910390fd5b8060036000828254019250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015613d685750600081115b15613fc457600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613e98576000601160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff1611613e0b576000613e6f565b601060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff168152602001908152602001600020600101545b90506000613e86848361468090919063ffffffff16565b9050613e9486848484614703565b5050505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614613fc3576000601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1690506000808263ffffffff1611613f36576000613f9a565b601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001840363ffffffff1663ffffffff168152602001908152602001600020600101545b90506000613fb18483613b3a90919063ffffffff16565b9050613fbf85848484614703565b5050505b5b505050565b6000600f60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600061403884611900565b905082600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a4614134828483613d2c565b50505050565b60008083141561414d57600090506141ba565b600082840290508284828161415e57fe5b04146141b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806150b76021913960400191505060405180910390fd5b809150505b92915050565b6000808211614237576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b81838161424057fe5b04905092915050565b6000804690508091505090565b6001600d60146101000a81548160ff0219169083151502179055506000600660019054906101000a900461ffff1690506000600660016101000a81548161ffff021916908361ffff16021790555060006142af30611900565b905060006142bb612704565b90508082116142ca57816142cc565b805b9150600b548210614389576000600b54905060006142f46002836141c090919063ffffffff16565b9050600061430b828461468090919063ffffffff16565b9050600047905061431b83614997565b6000614330824761468090919063ffffffff16565b905061433c8382614c4b565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb56184828560405180848152602001838152602001828152602001935050505060405180910390a150505050505b505080600660016101000a81548161ffff021916908361ffff160217905550506000600d60146101000a81548160ff021916908315150217905550565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561444c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614f476025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156144d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806151506023913960400191505060405180910390fd5b61453e8160405180606001604052806026815260200161512a60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a809092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506145d381600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b3a90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000828211156146f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b6000614727436040518060600160405280602e81526020016150fc602e9139614dbb565b905060008463ffffffff161180156147bc57508063ffffffff16601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001870363ffffffff1663ffffffff16815260200190815260200160002060000160009054906101000a900463ffffffff1663ffffffff16145b1561482d5781601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006001870363ffffffff1663ffffffff1681526020019081526020016000206001018190555061493a565b60405180604001604052808263ffffffff16815260200183815250601060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008663ffffffff1663ffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff1602179055506020820151816001015590505060018401601160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b8473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248484604051808381526020018281526020019250505060405180910390a25050505050565b6060600267ffffffffffffffff811180156149b157600080fd5b506040519080825280602002602001820160405280156149e05781602001602082028036833780820191505090505b50905030816000815181106149f157fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015614a9357600080fd5b505afa158015614aa7573d6000803e3d6000fd5b505050506040513d6020811015614abd57600080fd5b810190808051906020019092919050505081600181518110614adb57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050614b4230600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684613275565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015614c06578082015181840152602081019050614beb565b505050509050019650505050505050600060405180830381600087803b158015614c2f57600080fd5b505af1158015614c43573d6000803e3d6000fd5b505050505050565b614c7830600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684613275565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16426040518863ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018581526020018481526020018373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200196505050505050506060604051808303818588803b158015614d6457600080fd5b505af1158015614d78573d6000803e3d6000fd5b50505050506040513d6060811015614d8f57600080fd5b810190808051906020019092919080519060200190929190805190602001909291905050505050505050565b600064010000000083108290614e6c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614e31578082015181840152602081019050614e16565b50505050905090810190601f168015614e5e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082905092915050565b6040518060400160405280600063ffffffff16815260200160008152509056fe6765745072696f72566f7465733a206e6f74207965742064657465726d696e6564616e74695768616c653a205472616e7366657220616d6f756e74206578636565647320746865206d61785472616e73666572416d6f756e747570646174654d61785472616e73666572416d6f756e74526174653a204d6178207472616e7366657220616d6f756e742072617465206d757374206e6f742065786365656420746865206d6178696d756d20726174652e42455032303a207472616e736665722066726f6d20746865207a65726f20616464726573737570646174654275726e526174653a204275726e2072617465206d757374206e6f742065786365656420746865206d6178696d756d20726174652e42455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373757064617465546f6b656e53776170526f757465723a20496e76616c6964207061697220616464726573732e42455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63657570646174655472616e73666572546178526174653a205472616e73666572207461782072617465206d757374206e6f742065786365656420746865206d6178696d756d20726174652e5472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776f70657261746f723a2063616c6c6572206973206e6f7420746865206f70657261746f725f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747342455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a20617070726f766520746f20746865207a65726f2061646472657373a26469706673582212207dc2f58ca1797659460409d6c77d58b2ee8eb2ddbe92d0a6f13a451957516b1464736f6c634300060c0033
[ 4, 19, 11, 9, 13, 5 ]
0xf3b98d8c425c76e0c7abadffddc1a26ce3107e45
pragma solidity ^0.4.21; /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/openzeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) canMint internal returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() canMint internal returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract MTF is MintableToken, Ownable { using SafeMath for uint256; //The name of the token string public constant name = "MintFlint Token"; //The token symbol string public constant symbol = "MTF"; //The precision used in the balance calculations in contract uint8 public constant decimals = 18; //maximum cap to be sold on ICO uint256 public constant maxCap = 1500000000e18; //to save total number of ethers received uint256 public totalWeiReceived; //time when the sale starts uint256 public startTime; //time when the presale ends uint256 public endTime; //to check the sale status bool public paused; //events event StateChanged(bool); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); function MTF(uint256 _startTime, uint256 _endTime) public { startTime = _startTime; endTime = _endTime; paused = false; totalSupply_ = 0; } modifier whenSaleEnded() { require(now >= endTime); _; } /** * @dev to determine the timeframe of sale */ modifier validTimeframe() { require(!paused && now >=startTime && now < endTime); _; } /** * @dev Allocate tokens to team members */ function teamAllocation(address _airdropAddress) public onlyOwner whenSaleEnded { uint256 toDistribute = totalSupply_.mul(2); // Receiver1 3.0% uint256 part1 = toDistribute.mul(3).div(400); mint(0x1117Db9F1bf18C91233Bff3BF2676137709463B3, part1); mint(0x6C137b489cEE58C32fd8Aec66EAdC4B959550198, part1); mint(0x450023b2D943498949f0A9cdb1DbBd827844EE78, part1); mint(0x89080db76A555c42D7b43556E40AcaAFeB786CDD, part1); // Receiver2 19.5% uint256 part2 = toDistribute.mul(195).div(4000); mint(0xcFc43257606C6a642d9438dCd82bf5b39A17dbAB, part2); mint(0x4a8C5Ea0619c40070f288c8aC289ef2f6Bb87cff, part2); mint(0x947251376EeAFb0B0CD1bD47cC6056A5162bEaF4, part2); mint(0x39A49403eFB1e85F835A9e5dc82706B970D112e4, part2); // Receiver3 2.0% 0x733bc7201261aC3c9508D20a811D99179304240a mint(0x733bc7201261aC3c9508D20a811D99179304240a, toDistribute.mul(2).div(100)); // Receiver4 18.0% 0x4b6716bd349dC65d07152844ed4990C2077cF1a7 mint(0x4b6716bd349dC65d07152844ed4990C2077cF1a7, toDistribute.mul(18).div(100)); // Receiver5 6% 0xEf628A29668C00d5C7C4D915F07188dC96cF24eb uint256 part5 = toDistribute.mul(6).div(400); mint(0xEf628A29668C00d5C7C4D915F07188dC96cF24eb, part5); mint(0xF28a5e85316E0C950f8703e2d99F15A7c077014c, part5); mint(0x0c8C9Dcfa4ed27e02349D536fE30957a32b44a04, part5); mint(0x0A86174f18D145D3850501e2f4C160519207B829, part5); // Receiver6 1.50% // 0.75% in 0x35eeb3216E2Ff669F2c1Ff90A08A22F60e6c5728 and // 0.75% in 0x28dcC9Af670252A5f76296207cfcC29B4E3C68D5 mint(0x35eeb3216E2Ff669F2c1Ff90A08A22F60e6c5728, toDistribute.mul(75).div(10000)); mint(0x28dcC9Af670252A5f76296207cfcC29B4E3C68D5, toDistribute.mul(75).div(10000)); mint(_airdropAddress, 175000000 ether); finishMinting(); } function transfer(address _to, uint _value) whenSaleEnded public returns(bool _success) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) whenSaleEnded public returns (bool) { return super.transferFrom(_from, _to, _value); } /** * @dev Calculate number of tokens that will be received in one ether * */ function getPrice() public pure returns(uint256) { return 100000; } /** * @dev to enable pause sale for break in ICO and Pre-ICO * */ function pauseSale() public onlyOwner { require(!paused); paused = true; } /** * @dev to resume paused sale * */ function resumeSale() public onlyOwner { require(paused); paused = false; } function buyTokens(address beneficiary) internal validTimeframe { uint256 tokensBought = msg.value.mul(getPrice()); totalWeiReceived = totalWeiReceived.add(msg.value); emit TokenPurchase(beneficiary, msg.value, tokensBought); mint(beneficiary, tokensBought); require(totalSupply_ <= maxCap); } function () public payable { buyTokens(msg.sender); } /** * @dev Failsafe drain. */ function drain() public onlyOwner whenSaleEnded { owner.transfer(address(this).balance); } }
0x60806040526004361061013d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305d2035b811461014857806306fdde0314610171578063095ea7b3146101fb57806318160ddd1461021f57806323548b8b1461024657806323b872dd1461025b5780632a1ef0ca14610285578063313ce567146102a65780633197cbb6146102d157806333e364cb146102e657806355367ba9146102fb5780635c975abb14610310578063661884631461032557806370a082311461034957806378e979251461036a57806388d12a4d1461037f5780638da5cb5b1461039457806395d89b41146103c55780639890220b146103da57806398d5fdca146103ef578063a9059cbb14610404578063d73dd62314610428578063dd62ed3e1461044c578063f2fde38b14610473575b61014633610494565b005b34801561015457600080fd5b5061015d610562565b604080519115158252519081900360200190f35b34801561017d57600080fd5b5061018661056b565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101c05781810151838201526020016101a8565b50505050905090810190601f1680156101ed5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561020757600080fd5b5061015d600160a060020a03600435166024356105a2565b34801561022b57600080fd5b50610234610609565b60408051918252519081900360200190f35b34801561025257600080fd5b5061023461060f565b34801561026757600080fd5b5061015d600160a060020a036004358116906024351660443561061f565b34801561029157600080fd5b50610146600160a060020a0360043516610644565b3480156102b257600080fd5b506102bb610942565b6040805160ff9092168252519081900360200190f35b3480156102dd57600080fd5b50610234610947565b3480156102f257600080fd5b5061014661094d565b34801561030757600080fd5b50610146610986565b34801561031c57600080fd5b5061015d6109c1565b34801561033157600080fd5b5061015d600160a060020a03600435166024356109ca565b34801561035557600080fd5b50610234600160a060020a0360043516610aba565b34801561037657600080fd5b50610234610ad5565b34801561038b57600080fd5b50610234610adb565b3480156103a057600080fd5b506103a9610ae1565b60408051600160a060020a039092168252519081900360200190f35b3480156103d157600080fd5b50610186610af5565b3480156103e657600080fd5b50610146610b2c565b3480156103fb57600080fd5b50610234610b9b565b34801561041057600080fd5b5061015d600160a060020a0360043516602435610ba2565b34801561043457600080fd5b5061015d600160a060020a0360043516602435610bc5565b34801561045857600080fd5b50610234600160a060020a0360043581169060243516610c5e565b34801561047f57600080fd5b50610146600160a060020a0360043516610c89565b60075460009060ff161580156104ac57506005544210155b80156104b9575060065442105b15156104c457600080fd5b6104dc6104cf610b9b565b349063ffffffff610d2e16565b6004549091506104f2903463ffffffff610d5716565b60045560408051348152602081018390528151600160a060020a038516927fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f928290030190a26105428282610d64565b506001546b04d8c55aefb8c05b5c000000101561055e57600080fd5b5050565b60035460ff1681565b60408051808201909152600f81527f4d696e74466c696e7420546f6b656e0000000000000000000000000000000000602082015281565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60015490565b6b04d8c55aefb8c05b5c00000081565b60065460009042101561063157600080fd5b61063c848484610e50565b949350505050565b6003546000908190819081906101009004600160a060020a0316331461066957600080fd5b60065442101561067857600080fd5b60015461068c90600263ffffffff610d2e16565b93506106b16101906106a586600363ffffffff610d2e16565b9063ffffffff610fc716565b92506106d1731117db9f1bf18c91233bff3bf2676137709463b384610d64565b506106f0736c137b489cee58c32fd8aec66eadc4b95955019884610d64565b5061070f73450023b2d943498949f0a9cdb1dbbd827844ee7884610d64565b5061072e7389080db76a555c42d7b43556e40acaafeb786cdd84610d64565b50610746610fa06106a58660c363ffffffff610d2e16565b915061076673cfc43257606c6a642d9438dcd82bf5b39a17dbab83610d64565b50610785734a8c5ea0619c40070f288c8ac289ef2f6bb87cff83610d64565b506107a473947251376eeafb0b0cd1bd47cc6056a5162beaf483610d64565b506107c37339a49403efb1e85f835a9e5dc82706b970d112e483610d64565b506107f773733bc7201261ac3c9508d20a811d99179304240a6107f260646106a588600263ffffffff610d2e16565b610d64565b50610826734b6716bd349dc65d07152844ed4990c2077cf1a76107f260646106a588601263ffffffff610d2e16565b5061083e6101906106a586600663ffffffff610d2e16565b905061085e73ef628a29668c00d5c7c4d915f07188dc96cf24eb82610d64565b5061087d73f28a5e85316e0c950f8703e2d99f15a7c077014c82610d64565b5061089c730c8c9dcfa4ed27e02349d536fe30957a32b44a0482610d64565b506108bb730a86174f18d145d3850501e2f4c160519207b82982610d64565b506108eb7335eeb3216e2ff669f2c1ff90a08a22f60e6c57286107f26127106106a588604b63ffffffff610d2e16565b5061091b7328dcc9af670252a5f76296207cfcc29b4e3c68d56107f26127106106a588604b63ffffffff610d2e16565b50610931856a90c1b1025e16710f000000610d64565b5061093a610fdc565b505050505050565b601281565b60065481565b6003546101009004600160a060020a0316331461096957600080fd5b60075460ff16151561097a57600080fd5b6007805460ff19169055565b6003546101009004600160a060020a031633146109a257600080fd5b60075460ff16156109b257600080fd5b6007805460ff19166001179055565b60075460ff1681565b336000908152600260209081526040808320600160a060020a038616845290915281205480831115610a1f57336000908152600260209081526040808320600160a060020a0388168452909152812055610a54565b610a2f818463ffffffff61102b16565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b60055481565b60045481565b6003546101009004600160a060020a031681565b60408051808201909152600381527f4d54460000000000000000000000000000000000000000000000000000000000602082015281565b6003546101009004600160a060020a03163314610b4857600080fd5b600654421015610b5757600080fd5b600354604051600160a060020a036101009092049190911690303180156108fc02916000818181858888f19350505050158015610b98573d6000803e3d6000fd5b50565b620186a090565b600654600090421015610bb457600080fd5b610bbe838361103d565b9392505050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610bf9908363ffffffff610d5716565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b6003546101009004600160a060020a03163314610ca557600080fd5b600160a060020a0381161515610cba57600080fd5b600354604051600160a060020a0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a360038054600160a060020a039092166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179055565b6000821515610d3f57506000610603565b50818102818382811515610d4f57fe5b041461060357fe5b8181018281101561060357fe5b60035460009060ff1615610d7757600080fd5b600154610d8a908363ffffffff610d5716565b600155600160a060020a038316600090815260208190526040902054610db6908363ffffffff610d5716565b600160a060020a03841660008181526020818152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a038516916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350600192915050565b6000600160a060020a0383161515610e6757600080fd5b600160a060020a038416600090815260208190526040902054821115610e8c57600080fd5b600160a060020a0384166000908152600260209081526040808320338452909152902054821115610ebc57600080fd5b600160a060020a038416600090815260208190526040902054610ee5908363ffffffff61102b16565b600160a060020a038086166000908152602081905260408082209390935590851681522054610f1a908363ffffffff610d5716565b600160a060020a03808516600090815260208181526040808320949094559187168152600282528281203382529091522054610f5c908363ffffffff61102b16565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b60008183811515610fd457fe5b049392505050565b60035460009060ff1615610fef57600080fd5b6003805460ff191660011790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b60008282111561103757fe5b50900390565b6000600160a060020a038316151561105457600080fd5b3360009081526020819052604090205482111561107057600080fd5b33600090815260208190526040902054611090908363ffffffff61102b16565b3360009081526020819052604080822092909255600160a060020a038516815220546110c2908363ffffffff610d5716565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3506001929150505600a165627a7a723058206c6af26a52e445733074008058fdf1e30604cf99be5436e4013d1de4eadfcd9e0029
[ 38 ]
0xf3b9ee38cc20a79450198656fe69cdceea2a2655
pragma solidity ^0.4.24; // $$$$$$\ $$$$$$$$\ $$\ //$$ __$$\ $$ _____|\__| //$$ / \__| $$$$$$\ $$$$$$$\ $$$$$$\ $$ | $$\ $$$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$$\ $$$$$$\ //$$ | \____$$\ $$ __$$\ $$ __$$\ $$$$$\ $$ |$$ __$$\ \____$$\ $$ __$$\ $$ _____|$$ __$$\ //$$ | $$$$$$$ |$$ | $$ |$$$$$$$$ | $$ __| $$ |$$ | $$ | $$$$$$$ |$$ | $$ |$$ / $$$$$$$$ | //$$ | $$\ $$ __$$ |$$ | $$ |$$ ____| $$ | $$ |$$ | $$ |$$ __$$ |$$ | $$ |$$ | $$ ____| //\$$$$$$ |\$$$$$$$ |$$ | $$ |\$$$$$$$\ $$ | $$ |$$ | $$ |\$$$$$$$ |$$ | $$ |\$$$$$$$\ \$$$$$$$\ // \______/ \_______|\__| \__| \_______| \__| \__|\__| \__| \_______|\__| \__| \_______| \_______| // ---------------------------------------------------------------------------- // 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 // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract CaneFinance is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "CANE"; name = "CaneFinance"; decimals = 9; _totalSupply = 36000000000000; balances[0xba2E91c3531af1aa36F61Bb86a373352E8Ff1372] = _totalSupply; emit Transfer(address(0), 0xba2E91c3531af1aa36F61Bb86a373352E8Ff1372, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens in existence. */ /** * @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. * * > 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); } contract MultOwnable { address[] private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() internal { _owner.push(msg.sender); emit OwnershipTransferred(address(0), _owner[0]); } function checkOwner() private view returns (bool) { for (uint8 i = 0; i < _owner.length; i++) { if (_owner[i] == msg.sender) { return true; } } return false; } function checkNewOwner(address _address) private view returns (bool) { for (uint8 i = 0; i < _owner.length; i++) { if (_owner[i] == _address) { return false; } } return true; } modifier isAnOwner() { require(checkOwner(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public isAnOwner { for (uint8 i = 0; i < _owner.length; i++) { if (_owner[i] == msg.sender) { _owner[i] = address(0); emit OwnershipTransferred(_owner[i], msg.sender); } } } function getOwners() public view returns (address[] memory) { return _owner; } function addOwnerShip(address newOwner) public isAnOwner { _addOwnerShip(newOwner); } function _addOwnerShip(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); require(checkNewOwner(newOwner), "Owner already exists"); _owner.push(newOwner); emit OwnershipTransferred(_owner[_owner.length - 1], newOwner); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820182416475693821ebb415ac46c486002cbfd7a3c11985f2862c7689010ad57540029
[ 2, 18 ]
0xf3bb205393fafad9644c2c7315cecd45ac0ea815
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // File: @openzeppelin/contracts/token/ERC721/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/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/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; // 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 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/Strings.sol 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/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/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}. 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/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/utils/Counters.sol 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: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/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/SumItem.sol pragma solidity ^0.8.0; contract OwnableDelegateProxy { } contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } /** *On Rinkeby: "0xf57b2c51ded3a29e6891aba85459d600256cf317" *On mainnet: "0xa5409ec958c83c3f309868babaca7c86dcb077c1" **/ contract SumItem is ERC721URIStorage, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; address proxyRegistryAddress; constructor(address _proxyRegistryAddress) ERC721("SumSwap Collection", "SSC") { proxyRegistryAddress = _proxyRegistryAddress; } function isApprovedForAll(address owner,address operator) override public view returns (bool) { // Whitelist OpenSea proxy contract for easy trading. ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } function awardItem(address player, string memory tokenURI) public onlyOwner returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(player, newItemId); _setTokenURI(newItemId, tokenURI); return newItemId; } function withdrawETH() public onlyOwner{ payable(msg.sender).transfer(address(this).balance); } function withdrawToken(address addr) public onlyOwner{ IERC20(addr).transfer(_msgSender(), IERC20(addr).balanceOf(address(this))); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c806389476069116100ad578063c87b56dd11610071578063c87b56dd14610243578063cf37834314610256578063e086e5ec14610269578063e985e9c514610271578063f2fde38b1461028457610121565b806389476069146101fa5780638da5cb5b1461020d57806395d89b4114610215578063a22cb4651461021d578063b88d4fde1461023057610121565b806323b872dd116100f457806323b872dd1461019957806342842e0e146101ac5780636352211e146101bf57806370a08231146101d2578063715018a6146101f257610121565b806301ffc9a71461012657806306fdde031461014f578063081812fc14610164578063095ea7b314610184575b600080fd5b61013961013436600461152f565b610297565b6040516101469190611678565b60405180910390f35b6101576102df565b6040516101469190611683565b610177610172366004611583565b610371565b604051610146919061160e565b6101976101923660046114e8565b6103bd565b005b6101976101a736600461139d565b610455565b6101976101ba36600461139d565b61048d565b6101776101cd366004611583565b6104a8565b6101e56101e0366004611349565b6104dd565b6040516101469190611b9b565b610197610521565b610197610208366004611349565b6105aa565b6101776106ef565b6101576106fe565b61019761022b36600461145a565b61070d565b61019761023e3660046113dd565b6107db565b610157610251366004611583565b61081a565b6101e5610264366004611487565b61093b565b6101976109b1565b61013961027f366004611365565b610a1f565b610197610292366004611349565b610acb565b60006001600160e01b031982166380ac58cd60e01b14806102c857506001600160e01b03198216635b5e139f60e01b145b806102d757506102d782610b8c565b90505b919050565b6060600080546102ee90611c13565b80601f016020809104026020016040519081016040528092919081815260200182805461031a90611c13565b80156103675780601f1061033c57610100808354040283529160200191610367565b820191906000526020600020905b81548152906001019060200180831161034a57829003601f168201915b5050505050905090565b600061037c82610ba5565b6103a15760405162461bcd60e51b8152600401610398906119f0565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006103c8826104a8565b9050806001600160a01b0316836001600160a01b031614156103fc5760405162461bcd60e51b815260040161039890611b09565b806001600160a01b031661040e610bc2565b6001600160a01b0316148061042a575061042a8161027f610bc2565b6104465760405162461bcd60e51b81526004016103989061182c565b6104508383610bc6565b505050565b610466610460610bc2565b82610c34565b6104825760405162461bcd60e51b815260040161039890611b4a565b610450838383610cb1565b610450838383604051806020016040528060008152506107db565b6000818152600260205260408120546001600160a01b0316806102d75760405162461bcd60e51b8152600401610398906118d3565b60006001600160a01b0382166105055760405162461bcd60e51b815260040161039890611889565b506001600160a01b031660009081526003602052604090205490565b610529610bc2565b6001600160a01b031661053a6106ef565b6001600160a01b0316146105605760405162461bcd60e51b815260040161039890611a3c565b6007546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600780546001600160a01b0319169055565b6105b2610bc2565b6001600160a01b03166105c36106ef565b6001600160a01b0316146105e95760405162461bcd60e51b815260040161039890611a3c565b806001600160a01b031663a9059cbb610600610bc2565b6040516370a0823160e01b81526001600160a01b038516906370a082319061062c90309060040161160e565b60206040518083038186803b15801561064457600080fd5b505afa158015610658573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067c919061159b565b6040518363ffffffff1660e01b815260040161069992919061165f565b602060405180830381600087803b1580156106b357600080fd5b505af11580156106c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106eb9190611513565b5050565b6007546001600160a01b031690565b6060600180546102ee90611c13565b610715610bc2565b6001600160a01b0316826001600160a01b031614156107465760405162461bcd60e51b8152600401610398906117a9565b8060056000610753610bc2565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610797610bc2565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516107cf9190611678565b60405180910390a35050565b6107ec6107e6610bc2565b83610c34565b6108085760405162461bcd60e51b815260040161039890611b4a565b61081484848484610dde565b50505050565b606061082582610ba5565b6108415760405162461bcd60e51b81526004016103989061199f565b6000828152600660205260408120805461085a90611c13565b80601f016020809104026020016040519081016040528092919081815260200182805461088690611c13565b80156108d35780601f106108a8576101008083540402835291602001916108d3565b820191906000526020600020905b8154815290600101906020018083116108b657829003601f168201915b5050505050905060006108e4610e11565b90508051600014156108f8575090506102da565b81511561092a5780826040516020016109129291906115df565b604051602081830303815290604052925050506102da565b61093384610e23565b949350505050565b6000610945610bc2565b6001600160a01b03166109566106ef565b6001600160a01b03161461097c5760405162461bcd60e51b815260040161039890611a3c565b6109866008610ea6565b60006109926008610eaf565b905061099e8482610eb3565b6109a88184610f92565b90505b92915050565b6109b9610bc2565b6001600160a01b03166109ca6106ef565b6001600160a01b0316146109f05760405162461bcd60e51b815260040161039890611a3c565b60405133904780156108fc02916000818181858888f19350505050158015610a1c573d6000803e3d6000fd5b50565b60095460405163c455279160e01b81526000916001600160a01b039081169190841690829063c455279190610a5890889060040161160e565b60206040518083038186803b158015610a7057600080fd5b505afa158015610a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa89190611567565b6001600160a01b03161415610ac15760019150506109ab565b6109338484610fd6565b610ad3610bc2565b6001600160a01b0316610ae46106ef565b6001600160a01b031614610b0a5760405162461bcd60e51b815260040161039890611a3c565b6001600160a01b038116610b305760405162461bcd60e51b8152600401610398906116e8565b6007546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160e01b031981166301ffc9a760e01b14919050565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610bfb826104a8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610c3f82610ba5565b610c5b5760405162461bcd60e51b8152600401610398906117e0565b6000610c66836104a8565b9050806001600160a01b0316846001600160a01b03161480610ca15750836001600160a01b0316610c9684610371565b6001600160a01b0316145b8061093357506109338185610a1f565b826001600160a01b0316610cc4826104a8565b6001600160a01b031614610cea5760405162461bcd60e51b815260040161039890611a71565b6001600160a01b038216610d105760405162461bcd60e51b815260040161039890611765565b610d1b838383610450565b610d26600082610bc6565b6001600160a01b0383166000908152600360205260408120805460019290610d4f908490611bd0565b90915550506001600160a01b0382166000908152600360205260408120805460019290610d7d908490611ba4565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610de9848484610cb1565b610df584848484611004565b6108145760405162461bcd60e51b815260040161039890611696565b60408051602081019091526000815290565b6060610e2e82610ba5565b610e4a5760405162461bcd60e51b815260040161039890611aba565b6000610e54610e11565b90506000815111610e745760405180602001604052806000815250610e9f565b80610e7e8461111f565b604051602001610e8f9291906115df565b6040516020818303038152906040525b9392505050565b80546001019055565b5490565b6001600160a01b038216610ed95760405162461bcd60e51b81526004016103989061196a565b610ee281610ba5565b15610eff5760405162461bcd60e51b81526004016103989061172e565b610f0b60008383610450565b6001600160a01b0382166000908152600360205260408120805460019290610f34908490611ba4565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b610f9b82610ba5565b610fb75760405162461bcd60e51b81526004016103989061191c565b6000828152600660209081526040909120825161045092840190611240565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6000611018846001600160a01b031661123a565b1561111457836001600160a01b031663150b7a02611034610bc2565b8786866040518563ffffffff1660e01b81526004016110569493929190611622565b602060405180830381600087803b15801561107057600080fd5b505af19250505080156110a0575060408051601f3d908101601f1916820190925261109d9181019061154b565b60015b6110fa573d8080156110ce576040519150601f19603f3d011682016040523d82523d6000602084013e6110d3565b606091505b5080516110f25760405162461bcd60e51b815260040161039890611696565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610933565b506001949350505050565b60608161114457506040805180820190915260018152600360fc1b60208201526102da565b8160005b811561116e578061115881611c4e565b91506111679050600a83611bbc565b9150611148565b60008167ffffffffffffffff81111561119757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156111c1576020820181803683370190505b5090505b8415610933576111d6600183611bd0565b91506111e3600a86611c69565b6111ee906030611ba4565b60f81b81838151811061121157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611233600a86611bbc565b94506111c5565b3b151590565b82805461124c90611c13565b90600052602060002090601f01602090048101928261126e57600085556112b4565b82601f1061128757805160ff19168380011785556112b4565b828001600101855582156112b4579182015b828111156112b4578251825591602001919060010190611299565b506112c09291506112c4565b5090565b5b808211156112c057600081556001016112c5565b600067ffffffffffffffff808411156112f4576112f4611ca9565b604051601f8501601f19168101602001828111828210171561131857611318611ca9565b60405284815291508183850186101561133057600080fd5b8484602083013760006020868301015250509392505050565b60006020828403121561135a578081fd5b81356109a881611cbf565b60008060408385031215611377578081fd5b823561138281611cbf565b9150602083013561139281611cbf565b809150509250929050565b6000806000606084860312156113b1578081fd5b83356113bc81611cbf565b925060208401356113cc81611cbf565b929592945050506040919091013590565b600080600080608085870312156113f2578081fd5b84356113fd81611cbf565b9350602085013561140d81611cbf565b925060408501359150606085013567ffffffffffffffff81111561142f578182fd5b8501601f8101871361143f578182fd5b61144e878235602084016112d9565b91505092959194509250565b6000806040838503121561146c578182fd5b823561147781611cbf565b9150602083013561139281611cd4565b60008060408385031215611499578182fd5b82356114a481611cbf565b9150602083013567ffffffffffffffff8111156114bf578182fd5b8301601f810185136114cf578182fd5b6114de858235602084016112d9565b9150509250929050565b600080604083850312156114fa578182fd5b823561150581611cbf565b946020939093013593505050565b600060208284031215611524578081fd5b81516109a881611cd4565b600060208284031215611540578081fd5b81356109a881611ce2565b60006020828403121561155c578081fd5b81516109a881611ce2565b600060208284031215611578578081fd5b81516109a881611cbf565b600060208284031215611594578081fd5b5035919050565b6000602082840312156115ac578081fd5b5051919050565b600081518084526115cb816020860160208601611be7565b601f01601f19169290920160200192915050565b600083516115f1818460208801611be7565b835190830190611605818360208801611be7565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611655908301846115b3565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b600060208252610e9f60208301846115b3565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252602e908201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60408201526d32bc34b9ba32b73a103a37b5b2b760911b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b60208082526031908201527f45524337323155524953746f726167653a2055524920717565727920666f72206040820152703737b732bc34b9ba32b73a103a37b5b2b760791b606082015260800190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b90815260200190565b60008219821115611bb757611bb7611c7d565b500190565b600082611bcb57611bcb611c93565b500490565b600082821015611be257611be2611c7d565b500390565b60005b83811015611c02578181015183820152602001611bea565b838111156108145750506000910152565b600281046001821680611c2757607f821691505b60208210811415611c4857634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611c6257611c62611c7d565b5060010190565b600082611c7857611c78611c93565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a1c57600080fd5b8015158114610a1c57600080fd5b6001600160e01b031981168114610a1c57600080fdfea2646970667358221220657c89de26ee51224af4278e985776ac087158c96018ba0afe1358d7962d7ba464736f6c63430008000033
[ 16, 5 ]
0xF3bB2Bdb756e75c80FeF8cd2332b3b593fFB398E
/* 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.7.5; import "./lib/LibSafeMath.sol"; import "./lib/LibAddress.sol"; import "./ERC1155.sol"; import "./interface/IERC1155Mintable.sol"; import "./mixin/MixinOwnable.sol"; import "./mixin/MixinContractURI.sol"; import "./mixin/MixinTokenURI.sol"; /// @dev Mintable form of ERC1155 /// Shows how easy it is to mint new items contract ERC1155Mintable is IERC1155Mintable, ERC1155, MixinContractURI, MixinTokenURI { using LibSafeMath for uint256; using LibAddress for address; uint256 internal nonce; /// mapping from token to max index mapping (uint256 => uint256) public maxIndex; mapping (uint256 => mapping(address => bool)) internal creatorApproval; modifier onlyCreator(uint256 _id) { require(creatorApproval[_id][msg.sender], "not an approved creator of id"); _; } function setCreatorApproval(uint256 id, address creator, bool status) external onlyCreator(id) { creatorApproval[id][creator] = status; } /// @dev creates a new token /// @param isNF is non-fungible token /// @return type_ of token (a unique identifier) function create( bool isNF ) external override onlyOwner() returns (uint256 type_) { // Store the type in the upper 128 bits type_ = (++nonce << 128); // Set a flag if this is an NFI. if (isNF) { type_ = type_ | TYPE_NF_BIT; } creatorApproval[type_][msg.sender] = true; // emit a Transfer event with Create semantic to help with discovery. emit TransferSingle( msg.sender, address(0x0), address(0x0), type_, 0 ); emit URI(uri(type_), type_); } /// @dev creates a new token /// @param type_ of token function createWithType( uint256 type_ ) external onlyOwner() { creatorApproval[type_][msg.sender] = true; // emit a Transfer event with Create semantic to help with discovery. emit TransferSingle( msg.sender, address(0x0), address(0x0), type_, 0 ); emit URI(uri(type_), type_); } /// @dev mints fungible tokens /// @param id token type /// @param to beneficiaries of minted tokens /// @param quantities amounts of minted tokens function mintFungible( uint256 id, address[] calldata to, uint256[] calldata quantities ) external override onlyCreator(id) { // sanity checks require( isFungible(id), "TRIED_TO_MINT_FUNGIBLE_FOR_NON_FUNGIBLE_TOKEN" ); // mint tokens for (uint256 i = 0; i < to.length; ++i) { // cache to reduce number of loads address dst = to[i]; uint256 quantity = quantities[i]; // Grant the items to the caller balances[id][dst] = quantity.safeAdd(balances[id][dst]); // Emit the Transfer/Mint event. // the 0x0 source address implies a mint // It will also provide the circulating supply info. emit TransferSingle( msg.sender, address(0x0), dst, id, quantity ); // if `to` is a contract then trigger its callback if (dst.isContract()) { bytes4 callbackReturnValue = IERC1155Receiver(dst).onERC1155Received( msg.sender, msg.sender, id, quantity, "" ); require( callbackReturnValue == ERC1155_RECEIVED, "BAD_RECEIVER_RETURN_VALUE" ); } } } /// @dev mints a non-fungible token /// @param type_ token type /// @param to beneficiaries of minted tokens function mintNonFungible( uint256 type_, address[] calldata to ) external override onlyCreator(type_) { require( isNonFungible(type_), "TRIED_TO_MINT_NON_FUNGIBLE_FOR_FUNGIBLE_TOKEN" ); // Index are 1-based. uint256 index = maxIndex[type_] + 1; for (uint256 i = 0; i < to.length; ++i) { // cache to reduce number of loads address dst = to[i]; uint256 id = type_ | index + i; transferNFToken(id, address(0x0), dst); // You could use base-type id to store NF type balances if you wish. balances[type_][dst] = balances[type_][dst].safeAdd(1); emit TransferSingle(msg.sender, address(0x0), dst, id, 1); // if `to` is a contract then trigger its callback if (dst.isContract()) { bytes4 callbackReturnValue = IERC1155Receiver(dst).onERC1155Received( msg.sender, msg.sender, id, 1, "" ); require( callbackReturnValue == ERC1155_RECEIVED, "BAD_RECEIVER_RETURN_VALUE" ); } } // record the `maxIndex` of this nft type // this allows us to mint more nft's of this type in a subsequent call. maxIndex[type_] = to.length.safeAdd(maxIndex[type_]); } } /* 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.7.5; import "./LibRichErrors.sol"; import "./LibSafeMathRichErrors.sol"; library LibSafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; if (c / a != b) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW, a, b )); } return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO, a, b )); } uint256 c = a / b; return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { if (b > a) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW, a, b )); } return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; if (c < a) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW, a, b )); } return c; } 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 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.7.5; /** * Utility library of inline functions on addresses */ library LibAddress { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param account address of the account to check * @return whether the target address is a contract */ function isContract(address account) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } /* 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.7.5; import "./lib/LibSafeMath.sol"; import "./lib/LibAddress.sol"; import "./interface/IERC1155.sol"; import "./interface/IERC1155Receiver.sol"; import "./mixin/MixinNonFungibleToken.sol"; import "./mixin/MixinOwnable.sol"; import "./WhitelistExchangesProxy.sol"; contract ERC1155 is IERC1155, MixinNonFungibleToken, Ownable { using LibAddress for address; using LibSafeMath for uint256; // selectors for receiver callbacks bytes4 constant public ERC1155_RECEIVED = 0xf23a6e61; bytes4 constant public ERC1155_BATCH_RECEIVED = 0xbc197c81; // id => (owner => balance) mapping (uint256 => mapping(address => uint256)) internal balances; // owner => (operator => approved) mapping (address => mapping(address => bool)) internal operatorApproval; address public exchangesRegistry; function setExchangesRegistry(address newExchangesRegistry) external onlyOwner() { exchangesRegistry = newExchangesRegistry; } function burn(address from, uint256 id, uint256 amount) external { require( from == msg.sender || isApprovedForAll(from, msg.sender), "INSUFFICIENT_ALLOWANCE" ); require(isFungible(id), "Don't allow burn of NFTs via this function"); balances[id][from] = balances[id][from].safeSub(amount); emit TransferSingle(msg.sender, from, address(0x0), id, amount); } /// @notice Transfers value amount of an _id from the _from address to the _to address specified. /// @dev MUST emit TransferSingle event on success. /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll). /// MUST throw if `_to` is the zero address. /// MUST throw if balance of sender for token `_id` is lower than the `_value` sent. /// MUST throw on any other error. /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). /// If so, it MUST call `onERC1155Received` on `_to` and revert if the return value /// is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`. /// @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, sent in call to `_to` function safeTransferFrom( address from, address to, uint256 id, uint256 value, bytes calldata data ) override external { // sanity checks require( to != address(0x0), "CANNOT_TRANSFER_TO_ADDRESS_ZERO" ); require( from == msg.sender || isApprovedForAll(from, msg.sender), "INSUFFICIENT_ALLOWANCE" ); // perform transfer if (isNonFungible(id)) { require( value == 1, "AMOUNT_EQUAL_TO_ONE_REQUIRED" ); require( nfOwners[id] == from, "NFT_NOT_OWNED_BY_FROM_ADDRESS" ); transferNFToken(id, from, to); // You could keep balance of NF type in base type id like so: // uint256 baseType = getNonFungibleBaseType(_id); // balances[baseType][_from] = balances[baseType][_from].safeSub(_value); // balances[baseType][_to] = balances[baseType][_to].safeAdd(_value); } else { balances[id][from] = balances[id][from].safeSub(value); balances[id][to] = balances[id][to].safeAdd(value); } emit TransferSingle(msg.sender, from, to, id, value); // if `to` is a contract then trigger its callback if (to.isContract()) { bytes4 callbackReturnValue = IERC1155Receiver(to).onERC1155Received( msg.sender, from, id, value, data ); require( callbackReturnValue == ERC1155_RECEIVED, "BAD_RECEIVER_RETURN_VALUE" ); } } /// @notice Send multiple types of Tokens from a 3rd party in one transfer (with safety call). /// @dev MUST emit TransferBatch event on success. /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll). /// MUST throw if `_to` is the zero address. /// MUST throw if length of `_ids` is not the same as length of `_values`. /// MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent. /// MUST throw on any other error. /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). /// If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value /// is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`. /// @param from Source addresses /// @param to Target addresses /// @param ids IDs of each token type /// @param values Transfer amounts per token type /// @param data Additional data with no specified format, sent in call to `_to` function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) override external { // sanity checks require( to != address(0x0), "CANNOT_TRANSFER_TO_ADDRESS_ZERO" ); require( ids.length == values.length, "TOKEN_AND_VALUES_LENGTH_MISMATCH" ); // Only supporting a global operator approval allows us to do // only 1 check and not to touch storage to handle allowances. require( from == msg.sender || isApprovedForAll(from, msg.sender), "INSUFFICIENT_ALLOWANCE" ); // perform transfers for (uint256 i = 0; i < ids.length; ++i) { // Cache value to local variable to reduce read costs. uint256 id = ids[i]; uint256 value = values[i]; if (isNonFungible(id)) { require( value == 1, "AMOUNT_EQUAL_TO_ONE_REQUIRED" ); require( nfOwners[id] == from, "NFT_NOT_OWNED_BY_FROM_ADDRESS" ); transferNFToken(id, from, to); } else { balances[id][from] = balances[id][from].safeSub(value); balances[id][to] = balances[id][to].safeAdd(value); } } emit TransferBatch(msg.sender, from, to, ids, values); // if `to` is a contract then trigger its callback if (to.isContract()) { bytes4 callbackReturnValue = IERC1155Receiver(to).onERC1155BatchReceived( msg.sender, from, ids, values, data ); require( callbackReturnValue == ERC1155_BATCH_RECEIVED, "BAD_RECEIVER_RETURN_VALUE" ); } } /// @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. /// @dev MUST emit the ApprovalForAll event on success. /// @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 override { operatorApproval[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } /// @notice Queries the approval status of an operator for a given owner. /// @param owner The owner of the Tokens /// @param operator Address of authorized operator /// @return True if the operator is approved, false if not function isApprovedForAll(address owner, address operator) public override view returns (bool) { bool approved = operatorApproval[owner][operator]; if (!approved && exchangesRegistry != address(0)) { return WhitelistExchangesProxy(exchangesRegistry).isAddressWhitelisted(operator) == true; } return approved; } /// @notice Get the balance of an account's Tokens. /// @param owner The address of the token holder /// @param id ID of the Token /// @return The _owner's balance of the Token type requested function balanceOf(address owner, uint256 id) external override view returns (uint256) { if (isNonFungibleItem(id)) { return nfOwners[id] == owner ? 1 : 0; } return balances[id][owner]; } /// @notice Get the balance of multiple account/token pairs /// @param owners The addresses of the token holders /// @param ids ID of the Tokens /// @return balances_ The _owner's balance of the Token types requested function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) external override view returns (uint256[] memory balances_) { // sanity check require( owners.length == ids.length, "OWNERS_AND_IDS_MUST_HAVE_SAME_LENGTH" ); // get balances balances_ = new uint256[](owners.length); for (uint256 i = 0; i < owners.length; ++i) { uint256 id = ids[i]; if (isNonFungibleItem(id)) { balances_[i] = nfOwners[id] == owners[i] ? 1 : 0; } else { balances_[i] = balances[id][owners[i]]; } } return balances_; } bytes4 constant private INTERFACE_SIGNATURE_ERC165 = 0x01ffc9a7; bytes4 constant private INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26; function supportsInterface(bytes4 _interfaceID) external view returns (bool) { if (_interfaceID == INTERFACE_SIGNATURE_ERC165 || _interfaceID == INTERFACE_SIGNATURE_ERC1155) { return true; } return false; } } /* 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.7.5; import "./IERC1155.sol"; /// @dev Mintable form of ERC1155 /// Shows how easy it is to mint new items interface IERC1155Mintable is IERC1155 { /// @dev creates a new token /// @param isNF is non-fungible token /// @return type_ of token (a unique identifier) function create( bool isNF ) external returns (uint256 type_); /// @dev mints fungible tokens /// @param id token type /// @param to beneficiaries of minted tokens /// @param quantities amounts of minted tokens function mintFungible( uint256 id, address[] calldata to, uint256[] calldata quantities ) external; /// @dev mints a non-fungible token /// @param type_ token type /// @param to beneficiaries of minted tokens function mintNonFungible( uint256 type_, address[] calldata to ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.7.5; contract Context { function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @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 returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } pragma solidity ^0.7.5; import "./MixinOwnable.sol"; contract MixinContractURI is Ownable { string public contractURI; function setContractURI(string calldata newContractURI) external onlyOwner() { contractURI = newContractURI; } } pragma solidity ^0.7.5; import "./MixinOwnable.sol"; import "../lib/LibString.sol"; contract MixinTokenURI is Ownable { using LibString for string; string public baseMetadataURI = ""; function setBaseMetadataURI(string memory newBaseMetadataURI) public onlyOwner() { baseMetadataURI = newBaseMetadataURI; } function uri(uint256 _id) public view returns (string memory) { return LibString.strConcat( baseMetadataURI, LibString.uint2hexstr(_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.7.5; 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)) } } } /* 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.7.5; library LibSafeMathRichErrors { // bytes4(keccak256("Uint256BinOpError(uint8,uint256,uint256)")) bytes4 internal constant UINT256_BINOP_ERROR_SELECTOR = 0xe946c1bb; // bytes4(keccak256("Uint256DowncastError(uint8,uint256)")) bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR = 0xc996af7b; enum BinOpErrorCodes { ADDITION_OVERFLOW, MULTIPLICATION_OVERFLOW, SUBTRACTION_UNDERFLOW, DIVISION_BY_ZERO } enum DowncastErrorCodes { VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT32, VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT64, VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT96 } // solhint-disable func-name-mixedcase function Uint256BinOpError( BinOpErrorCodes errorCode, uint256 a, uint256 b ) internal pure returns (bytes memory) { return abi.encodeWithSelector( UINT256_BINOP_ERROR_SELECTOR, errorCode, a, b ); } function Uint256DowncastError( DowncastErrorCodes errorCode, uint256 a ) internal pure returns (bytes memory) { return abi.encodeWithSelector( UINT256_DOWNCAST_ERROR_SELECTOR, errorCode, a ); } } /* 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.7.5; /// @title ERC-1155 Multi Token Standard /// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md /// Note: The ERC-165 identifier for this interface is 0xd9b67a26. interface IERC1155 { /// @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, /// including zero value transfers as well as minting or burning. /// Operator will always be msg.sender. /// Either event from address `0x0` signifies a minting operation. /// An event to address `0x0` signifies a burning or melting operation. /// The total value transferred from address 0x0 minus the total value transferred to 0x0 may /// be used by clients and exchanges to be added to the "circulating supply" for a given token ID. /// To define a token ID with no initial balance, the contract SHOULD emit the TransferSingle event /// from `0x0` to `0x0`, with the token creator as `_operator`. event TransferSingle( address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value ); /// @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, /// including zero value transfers as well as minting or burning. ///Operator will always be msg.sender. /// Either event from address `0x0` signifies a minting operation. /// An event to address `0x0` signifies a burning or melting operation. /// The total value transferred from address 0x0 minus the total value transferred to 0x0 may /// be used by clients and exchanges to be added to the "circulating supply" for a given token ID. /// To define multiple token IDs with no initial balance, this SHOULD emit the TransferBatch event /// from `0x0` to `0x0`, with the token creator as `_operator`. event TransferBatch( address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values ); /// @dev MUST emit when an approval is updated. event ApprovalForAll( address indexed _owner, address indexed _operator, bool _approved ); /// @dev MUST emit when the URI is updated for a token ID. /// URIs are defined in RFC 3986. /// The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata JSON Schema". event URI( string _value, uint256 indexed _id ); /// @notice Transfers value amount of an _id from the _from address to the _to address specified. /// @dev MUST emit TransferSingle event on success. /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll). /// MUST throw if `_to` is the zero address. /// MUST throw if balance of sender for token `_id` is lower than the `_value` sent. /// MUST throw on any other error. /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). /// If so, it MUST call `onERC1155Received` on `_to` and revert if the return value /// is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`. /// @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, sent in call to `_to` function safeTransferFrom( address from, address to, uint256 id, uint256 value, bytes calldata data ) external; /// @notice Send multiple types of Tokens from a 3rd party in one transfer (with safety call). /// @dev MUST emit TransferBatch event on success. /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll). /// MUST throw if `_to` is the zero address. /// MUST throw if length of `_ids` is not the same as length of `_values`. /// MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent. /// MUST throw on any other error. /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). /// If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value /// is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`. /// @param from Source addresses /// @param to Target addresses /// @param ids IDs of each token type /// @param values Transfer amounts per token type /// @param data Additional data with no specified format, sent in call to `_to` function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; /// @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. /// @dev MUST emit the ApprovalForAll event on success. /// @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 Queries the approval status of an operator for a given owner. /// @param owner The owner of the Tokens /// @param operator Address of authorized operator /// @return True if the operator is approved, false if not function isApprovedForAll(address owner, address operator) external view returns (bool); /// @notice Get the balance of an account's Tokens. /// @param owner The address of the token holder /// @param id ID of the Token /// @return The _owner's balance of the Token type requested function balanceOf(address owner, uint256 id) external view returns (uint256); /// @notice Get the balance of multiple account/token pairs /// @param owners The addresses of the token holders /// @param ids ID of the Tokens /// @return balances_ The _owner's balance of the Token types requested function balanceOfBatch( address[] calldata owners, uint256[] calldata ids ) external view returns (uint256[] memory balances_); } /* 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.7.5; interface IERC1155Receiver { /// @notice Handle the receipt of a single ERC1155 token type /// @dev The smart contract calls this function on the recipient /// after a `safeTransferFrom`. This function MAY throw to revert and reject the /// transfer. Return of other than the magic value MUST result in the ///transaction being reverted /// Note: the contract address is always the message sender /// @param operator The address which called `safeTransferFrom` function /// @param from The address which previously owned the token /// @param id An array containing the ids of the token being transferred /// @param value An array containing the amount of tokens being transferred /// @param data Additional data with no specified format /// @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns(bytes4); /// @notice Handle the receipt of multiple ERC1155 token types /// @dev The smart contract calls this function on the recipient /// after a `safeTransferFrom`. This function MAY throw to revert and reject the /// transfer. Return of other than the magic value MUST result in the /// transaction being reverted /// Note: the contract address is always the message sender /// @param operator The address which called `safeTransferFrom` function /// @param from The address which previously owned the token /// @param ids An array containing ids of each token being transferred /// @param values An array containing amounts of each token being transferred /// @param data Additional data with no specified format /// @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns(bytes4); } /* 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.7.5; contract MixinNonFungibleToken { uint256 constant internal TYPE_MASK = uint256(uint128(~0)) << 128; uint256 constant internal NF_INDEX_MASK = uint128(~0); uint256 constant internal TYPE_NF_BIT = 1 << 255; mapping (uint256 => address) internal nfOwners; mapping (address => uint256[]) internal nfOwnerMapping; // One index as a hack to tell the diff between unset and 0-value mapping (uint256 => uint256) internal tokenIdToNFOwnerMappingOneIndex; /// @dev Returns true if token is non-fungible function isNonFungible(uint256 id) public pure returns(bool) { return id & TYPE_NF_BIT == TYPE_NF_BIT; } /// @dev Returns true if token is fungible function isFungible(uint256 id) public pure returns(bool) { return id & TYPE_NF_BIT == 0; } /// @dev Returns index of non-fungible token function getNonFungibleIndex(uint256 id) public pure returns(uint256) { return id & NF_INDEX_MASK; } /// @dev Returns base type of non-fungible token function getNonFungibleBaseType(uint256 id) public pure returns(uint256) { return id & TYPE_MASK; } /// @dev Returns true if input is base-type of a non-fungible token function isNonFungibleBaseType(uint256 id) public pure returns(bool) { // A base type has the NF bit but does not have an index. return (id & TYPE_NF_BIT == TYPE_NF_BIT) && (id & NF_INDEX_MASK == 0); } /// @dev Returns true if input is a non-fungible token function isNonFungibleItem(uint256 id) public pure returns(bool) { // A base type has the NF bit but does has an index. return (id & TYPE_NF_BIT == TYPE_NF_BIT) && (id & NF_INDEX_MASK != 0); } /// @dev returns owner of a non-fungible token function ownerOf(uint256 id) public view returns (address) { return nfOwners[id]; } /// @dev returns all owned NF tokenIds given an address function nfTokensOf(address _address) external view returns (uint256[] memory) { return nfOwnerMapping[_address]; } /// @dev transfer token from one NF owner to another function transferNFToken(uint256 _id, address _from, address _to) internal { require(nfOwners[_id] == _from, "Token not owned by the from address"); // chage nfOwner of the id to the new address nfOwners[_id] = _to; // only delete from the "from" user if this tokenId mapping already exists. When the from is 0x0 then it won't if (tokenIdToNFOwnerMappingOneIndex[_id] != 0) { // get index of where the token ID is stored in the from user's array of token IDs uint256 fromTokenIdIndex = tokenIdToNFOwnerMappingOneIndex[_id] - 1; // move the last token of the from user's array of token IDs to where fromTokenIdIndex is so we can shrink the array uint256 tokenIdToMove = nfOwnerMapping[_from][nfOwnerMapping[_from].length-1]; // make the moves and then shrink the array. make sure to move the reference of the index in the tokenIdToNFOwnerMappingOneIndex nfOwnerMapping[_from][fromTokenIdIndex] = tokenIdToMove; nfOwnerMapping[_from].pop(); tokenIdToNFOwnerMappingOneIndex[tokenIdToMove] = fromTokenIdIndex + 1; } // move the tokenId to the "to" user (and override index) nfOwnerMapping[_to].push(_id); tokenIdToNFOwnerMappingOneIndex[_id] = nfOwnerMapping[_to].length; // no need -1 because 1-index } } pragma solidity ^0.7.5; import "./mixin/MixinOwnable.sol"; contract WhitelistExchangesProxy is Ownable { mapping(address => bool) internal proxies; bool public paused = true; function setPaused(bool newPaused) external onlyOwner() { paused = newPaused; } function updateProxyAddress(address proxy, bool status) external onlyOwner() { proxies[proxy] = status; } function isAddressWhitelisted(address proxy) external view returns (bool) { if (paused) { return false; } else { return proxies[proxy]; } } } pragma solidity ^0.7.5; library LibString { // via https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (uint i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (uint i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (uint i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (uint i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b) internal pure returns (string memory) { return strConcat(_a, _b, "", "", ""); } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } function uint2hexstr(uint i) internal pure returns (string memory) { if (i == 0) { return "0"; } uint j = i; uint len; while (j != 0) { len++; j = j >> 4; } uint mask = 15; bytes memory bstr = new bytes(len); uint k = len - 1; while (i != 0){ uint curr = (i & mask); bstr[k--] = curr > 9 ? byte(uint8(55 + curr)) : byte(uint8(48 + curr)); i = i >> 4; } return string(bstr); } }
0x608060405234801561001057600080fd5b50600436106102055760003560e01c80638da5cb5b1161011a578063e0a5c949116100ad578063f242432a1161007c578063f242432a14610e5e578063f2fde38b14610f2b578063f5298aca14610f6f578063f941908814610fc7578063fc67bf1c1461104a57610205565b8063e0a5c94914610ce0578063e44591f014610d1d578063e8a3d48514610d61578063e985e9c514610de457610205565b8063a22cb465116100e9578063a22cb46514610bae578063adebf6f214610bfe578063c196cd7a14610c42578063db5a4ce614610c9c57610205565b80638da5cb5b14610a7b57806390a2f59214610aaf578063938e3d7b14610af35780639cca1c6414610b6c57610205565b80634e1273f41161019d5780636f969c2d1161016c5780636f969c2d14610858578063715018a61461089a5780637269a327146108a457806378b27221146108e85780637e518ec8146109c057610205565b80634e1273f4146106165780635b2bd79e146107395780635e81b958146107bc5780636352211e1461080057610205565b80630e89341c116101d95780630e89341c146103aa5780632eb2c2d6146104515780633115fc5c146105b457806348f62107146105e257610205565b8062fdd58e1461020a57806301ffc9a71461026c57806308d7d469146102cf5780630cfa157d14610311575b600080fd5b6102566004803603604081101561022057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611087565b6040518082815260200191505060405180910390f35b6102b76004803603602081101561028257600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916906020019092919050505061116a565b60405180821515815260200191505060405180910390f35b6102fb600480360360208110156102e557600080fd5b810190808035906020019092919050505061121b565b6040518082815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611233565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561039657808201518184015260208101905061037b565b505050509050019250505060405180910390f35b6103d6600480360360208110156103c057600080fd5b81019080803590602001909291905050506112ca565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104165780820151818401526020810190506103fb565b50505050905090810190601f1680156104435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105b2600480360360a081101561046757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156104c457600080fd5b8201836020820111156104d657600080fd5b803590602001918460208302840111640100000000831117156104f857600080fd5b90919293919293908035906020019064010000000081111561051957600080fd5b82018360208201111561052b57600080fd5b8035906020019184602083028401116401000000008311171561054d57600080fd5b90919293919293908035906020019064010000000081111561056e57600080fd5b82018360208201111561058057600080fd5b803590602001918460018302840111640100000000831117156105a257600080fd5b909192939192939050505061137f565b005b6105e0600480360360208110156105ca57600080fd5b8101908080359060200190929190505050611ba3565b005b6105ea611e05565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106e26004803603604081101561062c57600080fd5b810190808035906020019064010000000081111561064957600080fd5b82018360208201111561065b57600080fd5b8035906020019184602083028401116401000000008311171561067d57600080fd5b90919293919293908035906020019064010000000081111561069e57600080fd5b8201836020820111156106b057600080fd5b803590602001918460208302840111640100000000831117156106d257600080fd5b9091929391929390505050611e2b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561072557808201518184015260208101905061070a565b505050509050019250505060405180910390f35b610741612068565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610781578082015181840152602081019050610766565b50505050905090810190601f1680156107ae5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6107e8600480360360208110156107d257600080fd5b8101908080359060200190929190505050612106565b60405180821515815260200191505060405180910390f35b61082c6004803603602081101561081657600080fd5b8101908080359060200190929190505050612175565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6108846004803603602081101561086e57600080fd5b81019080803590602001909291905050506121b1565b6040518082815260200191505060405180910390f35b6108a26121f3565b005b6108d0600480360360208110156108ba57600080fd5b810190808035906020019092919050505061237e565b60405180821515815260200191505060405180910390f35b6109be600480360360608110156108fe57600080fd5b81019080803590602001909291908035906020019064010000000081111561092557600080fd5b82018360208201111561093757600080fd5b8035906020019184602083028401116401000000008311171561095957600080fd5b90919293919293908035906020019064010000000081111561097a57600080fd5b82018360208201111561098c57600080fd5b803590602001918460208302840111640100000000831117156109ae57600080fd5b90919293919293905050506123ec565b005b610a79600480360360208110156109d657600080fd5b81019080803590602001906401000000008111156109f357600080fd5b820183602082011115610a0557600080fd5b80359060200191846001830284011164010000000083111715610a2757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050612889565b005b610a8361296d565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610af160048036036020811015610ac557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612997565b005b610b6a60048036036020811015610b0957600080fd5b8101908080359060200190640100000000811115610b2657600080fd5b820183602082011115610b3857600080fd5b80359060200191846001830284011164010000000083111715610b5a57600080fd5b9091929391929390505050612aa5565b005b610b9860048036036020811015610b8257600080fd5b8101908080359060200190929190505050612b85565b6040518082815260200191505060405180910390f35b610bfc60048036036040811015610bc457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050612bc3565b005b610c2a60048036036020811015610c1457600080fd5b8101908080359060200190929190505050612cc2565b60405180821515815260200191505060405180910390f35b610c9a60048036036060811015610c5857600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050612cf0565b005b610cca60048036036020811015610cb257600080fd5b81019080803515159060200190929190505050612e2f565b6040518082815260200191505060405180910390f35b610ce86130d6565b60405180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b610d4960048036036020811015610d3357600080fd5b81019080803590602001909291905050506130e1565b60405180821515815260200191505060405180910390f35b610d6961310f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610da9578082015181840152602081019050610d8e565b50505050905090810190601f168015610dd65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610e4660048036036040811015610dfa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506131ad565b60405180821515815260200191505060405180910390f35b610f29600480360360a0811015610e7457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190640100000000811115610ee557600080fd5b820183602082011115610ef757600080fd5b80359060200191846001830284011164010000000083111715610f1957600080fd5b909192939192939050505061337c565b005b610f6d60048036036020811015610f4157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050613a1d565b005b610fc560048036036060811015610f8557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050613c2d565b005b61104860048036036040811015610fdd57600080fd5b81019080803590602001909291908035906020019064010000000081111561100457600080fd5b82018360208201111561101657600080fd5b8035906020019184602083028401116401000000008311171561103857600080fd5b9091929391929390505050613e7e565b005b611052614376565b60405180827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200191505060405180910390f35b600061109282612106565b15611110578273ffffffffffffffffffffffffffffffffffffffff1660008084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611103576000611106565b60015b60ff169050611164565b6004600083815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b92915050565b60006301ffc9a760e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611203575063d9b67a2660e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b156112115760019050611216565b600090505b919050565b600a6020528060005260406000206000915090505481565b6060600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156112be57602002820191906000526020600020905b8154815260200190600101908083116112aa575b50505050509050919050565b606061137860088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113655780601f1061133a57610100808354040283529160200191611365565b820191906000526020600020905b81548152906001019060200180831161134857829003601f168201915b505050505061137384614381565b6144d3565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff161415611422576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f0081525060200191505060405180910390fd5b83839050868690501461149d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f544f4b454e5f414e445f56414c5545535f4c454e4754485f4d49534d4154434881525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff1614806114dd57506114dc88336131ad565b5b61154f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f494e53554646494349454e545f414c4c4f57414e43450000000000000000000081525060200191505060405180910390fd5b60005b8686905081101561186e57600087878381811061156b57fe5b905060200201359050600086868481811061158257fe5b905060200201359050611594826130e1565b156116f2576001811461160f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f414d4f554e545f455155414c5f544f5f4f4e455f52455155495245440000000081525060200191505060405180910390fd5b8a73ffffffffffffffffffffffffffffffffffffffff1660008084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146116e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4e46545f4e4f545f4f574e45445f42595f46524f4d5f4144445245535300000081525060200191505060405180910390fd5b6116ed828c8c614517565b611861565b611755816004600085815260200190815260200160002060008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461488b90919063ffffffff16565b6004600084815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061180c816004600085815260200190815260200160002060008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546148b590919063ffffffff16565b6004600084815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5050806001019050611552565b508673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb898989896040518080602001806020018381038352878782818152602001925060200280828437600081840152601f19601f8201169050808301925050508381038252858582818152602001925060200280828437600081840152601f19601f820116905080830192505050965050505050505060405180910390a46119708773ffffffffffffffffffffffffffffffffffffffff166148e4565b15611b995760008773ffffffffffffffffffffffffffffffffffffffff1663bc197c81338b8a8a8a8a8a8a6040518963ffffffff1660e01b8152600401808973ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff16815260200180602001806020018060200184810384528a8a82818152602001925060200280828437600081840152601f19601f8201169050808301925050508481038352888882818152602001925060200280828437600081840152601f19601f8201169050808301925050508481038252868682818152602001925080828437600081840152601f19601f8201169050808301925050509b505050505050505050505050602060405180830381600087803b158015611aa057600080fd5b505af1158015611ab4573d6000803e3d6000fd5b505050506040513d6020811015611aca57600080fd5b8101908080519060200190929190505050905063bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614611b97576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4241445f52454345495645525f52455455524e5f56414c55450000000000000081525060200191505060405180910390fd5b505b5050505050505050565b611bab6148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611c6d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600b600083815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62846000604051808381526020018281526020019250505060405180910390a4807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b611d88836112ca565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015611dc8578082015181840152602081019050611dad565b50505050905090810190601f168015611df55780820380516001836020036101000a031916815260200191505b509250505060405180910390a250565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060828290508585905014611e8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614e476024913960400191505060405180910390fd5b8484905067ffffffffffffffff81118015611ea557600080fd5b50604051908082528060200260200182016040528015611ed45781602001602082028036833780820191505090505b50905060005b8585905081101561205f576000848483818110611ef357fe5b905060200201359050611f0581612106565b15611fc157868683818110611f1657fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611f9e576000611fa1565b60015b60ff16838381518110611fb057fe5b602002602001018181525050612053565b600460008281526020019081526020016000206000888885818110611fe257fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483838151811061204657fe5b6020026020010181815250505b50806001019050611eda565b50949350505050565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156120fe5780601f106120d3576101008083540402835291602001916120fe565b820191906000526020600020905b8154815290600101906020018083116120e157829003601f168201915b505050505081565b60007f800000000000000000000000000000000000000000000000000000000000000080831614801561216e575060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff16831614155b9050919050565b600080600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff16901b82169050919050565b6121fb6148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146122bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60007f80000000000000000000000000000000000000000000000000000000000000008083161480156123e5575060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff168316145b9050919050565b84600b600082815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166124bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f6e6f7420616e20617070726f7665642063726561746f72206f6620696400000081525060200191505060405180910390fd5b6124c686612cc2565b61251b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180614e6b602d913960400191505060405180910390fd5b60005b8585905081101561288057600086868381811061253757fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff169050600085858481811061256457fe5b9050602002013590506125d0600460008b815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826148b590919063ffffffff16565b600460008b815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628c85604051808381526020018281526020019250505060405180910390a46126c88273ffffffffffffffffffffffffffffffffffffffff166148e4565b156128735760008273ffffffffffffffffffffffffffffffffffffffff1663f23a6e6133338d866040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020018060200182810382526000815260200160200195505050505050602060405180830381600087803b15801561277a57600080fd5b505af115801561278e573d6000803e3d6000fd5b505050506040513d60208110156127a457600080fd5b8101908080519060200190929190505050905063f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614612871576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4241445f52454345495645525f52455455524e5f56414c55450000000000000081525060200191505060405180910390fd5b505b505080600101905061251e565b50505050505050565b6128916148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612953576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060089080519060200190612969929190614c6d565b5050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61299f6148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612a61576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b612aad6148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612b6f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b818160079190612b80929190614cfb565b505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6fffffffffffffffffffffffffffffffff1682169050919050565b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6000807f80000000000000000000000000000000000000000000000000000000000000008316149050919050565b82600b600082815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612dc1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f6e6f7420616e20617070726f7665642063726561746f72206f6620696400000081525060200191505060405180910390fd5b81600b600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050505050565b6000612e396148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612efb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6080600960008154600101919050819055901b90508115612f3c577f8000000000000000000000000000000000000000000000000000000000000000811790505b6001600b600083815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62846000604051808381526020018281526020019250505060405180910390a4807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b613057836112ca565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561309757808201518184015260208101905061307c565b50505050905090810190601f1680156130c45780820380516001836020036101000a031916815260200191505b509250505060405180910390a2919050565b63f23a6e6160e01b81565b60007f8000000000000000000000000000000000000000000000000000000000000000808316149050919050565b60078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156131a55780601f1061317a576101008083540402835291602001916131a5565b820191906000526020600020905b81548152906001019060200180831161318857829003601f168201915b505050505081565b600080600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050801580156132995750600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b156133715760011515600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166313f44d10856040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561332b57600080fd5b505afa15801561333f573d6000803e3d6000fd5b505050506040513d602081101561335557600080fd5b8101908080519060200190929190505050151514915050613376565b809150505b92915050565b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561341f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f43414e4e4f545f5452414e534645525f544f5f414444524553535f5a45524f0081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16148061345f575061345e86336131ad565b5b6134d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f494e53554646494349454e545f414c4c4f57414e43450000000000000000000081525060200191505060405180910390fd5b6134da846130e1565b156136385760018314613555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f414d4f554e545f455155414c5f544f5f4f4e455f52455155495245440000000081525060200191505060405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1660008086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613628576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4e46545f4e4f545f4f574e45445f42595f46524f4d5f4144445245535300000081525060200191505060405180910390fd5b613633848787614517565b6137a7565b61369b836004600087815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461488b90919063ffffffff16565b6004600086815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550613752836004600087815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546148b590919063ffffffff16565b6004600086815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628787604051808381526020018281526020019250505060405180910390a461384a8573ffffffffffffffffffffffffffffffffffffffff166148e4565b15613a155760008573ffffffffffffffffffffffffffffffffffffffff1663f23a6e613389888888886040518763ffffffff1660e01b8152600401808773ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f820116905080830192505050975050505050505050602060405180830381600087803b15801561391c57600080fd5b505af1158015613930573d6000803e3d6000fd5b505050506040513d602081101561394657600080fd5b8101908080519060200190929190505050905063f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614613a13576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4241445f52454345495645525f52455455524e5f56414c55450000000000000081525060200191505060405180910390fd5b505b505050505050565b613a256148f7565b73ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614613ae7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415613b6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614dca6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b3373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480613c6d5750613c6c83336131ad565b5b613cdf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f494e53554646494349454e545f414c4c4f57414e43450000000000000000000081525060200191505060405180910390fd5b613ce882612cc2565b613d3d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614df0602a913960400191505060405180910390fd5b613da0816004600085815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461488b90919063ffffffff16565b6004600084815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051808381526020018281526020019250505060405180910390a4505050565b82600b600082815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16613f4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f6e6f7420616e20617070726f7665642063726561746f72206f6620696400000081525060200191505060405180910390fd5b613f58846130e1565b613fad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d815260200180614e1a602d913960400191505060405180910390fd5b60006001600a60008781526020019081526020016000205401905060005b8484905081101561432e576000858583818110613fe457fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff16905060008284018817905061401881600084614517565b61407c6001600460008b815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546148b590919063ffffffff16565b600460008a815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62846001604051808381526020018281526020019250505060405180910390a46141758273ffffffffffffffffffffffffffffffffffffffff166148e4565b156143215760008273ffffffffffffffffffffffffffffffffffffffff1663f23a6e6133338560016040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020018060200182810382526000815260200160200195505050505050602060405180830381600087803b15801561422857600080fd5b505af115801561423c573d6000803e3d6000fd5b505050506040513d602081101561425257600080fd5b8101908080519060200190929190505050905063f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461431f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4241445f52454345495645525f52455455524e5f56414c55450000000000000081525060200191505060405180910390fd5b505b5050806001019050613fcb565b50614358600a600087815260200190815260200160002054858590506148b590919063ffffffff16565b600a6000878152602001908152602001600020819055505050505050565b63bc197c8160e01b81565b606060008214156143c9576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506144ce565b600082905060005b600082146143ed578080600101915050600482901c91506143d1565b6000600f905060608267ffffffffffffffff8111801561440c57600080fd5b506040519080825280601f01601f19166020018201604052801561443f5781602001600182028036833780820191505090505b50905060006001840390505b600087146144c557600083881690506009811161446e578060300160f81b614476565b8060370160f81b5b8383806001900394508151811061448957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600488901c97505061444b565b81955050505050505b919050565b606061450f83836040518060200160405280600081525060405180602001604052806000815250604051806020016040528060008152506148ff565b905092915050565b8173ffffffffffffffffffffffffffffffffffffffff1660008085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146145cd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614da76023913960400191505060405180910390fd5b8060008085815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006002600085815260200190815260200160002054146147c6576000600160026000868152602001908152602001600020540390506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060018060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905003815481106146e457fe5b9060005260206000200154905080600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020838154811061473c57fe5b9060005260206000200181905550600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080548061479257fe5b6001900381819060005260206000200160009055905560018201600260008381526020019081526020016000208190555050505b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020839080600181540180825580915050600190039060005260206000200160009091909190915055600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506002600085815260200190815260200160002081905550505050565b6000828211156148aa576148a96148a460028585614bc9565b614c65565b5b818303905092915050565b6000808284019050838110156148da576148d96148d460008686614bc9565b614c65565b5b8091505092915050565b600080823b905060008111915050919050565b600033905090565b60608086905060608690506060869050606086905060608690506060815183518551875189510101010167ffffffffffffffff8111801561493f57600080fd5b506040519080825280601f01601f1916602001820160405280156149725781602001600182028036833780820191505090505b50905060608190506000805b88518110156149ec5788818151811061499357fe5b602001015160f81c60f81b8383806001019450815181106149b057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350808060010191505061497e565b5060005b8751811015614a5e57878181518110614a0557fe5b602001015160f81c60f81b838380600101945081518110614a2257fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506149f0565b5060005b8651811015614ad057868181518110614a7757fe5b602001015160f81c60f81b838380600101945081518110614a9457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050614a62565b5060005b8551811015614b4257858181518110614ae957fe5b602001015160f81c60f81b838380600101945081518110614b0657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050614ad4565b5060005b8451811015614bb457848181518110614b5b57fe5b602001015160f81c60f81b838380600101945081518110614b7857fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508080600101915050614b46565b50819850505050505050505095945050505050565b606063e946c1bb60e01b84848460405160240180846003811115614be957fe5b81526020018381526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090509392505050565b805160208201fd5b828054600181600116156101000203166002900490600052602060002090601f016020900481019282614ca35760008555614cea565b82601f10614cbc57805160ff1916838001178555614cea565b82800160010185558215614cea579182015b82811115614ce9578251825591602001919060010190614cce565b5b509050614cf79190614d89565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282614d315760008555614d78565b82601f10614d4a57803560ff1916838001178555614d78565b82800160010185558215614d78579182015b82811115614d77578235825591602001919060010190614d5c565b5b509050614d859190614d89565b5090565b5b80821115614da2576000816000905550600101614d8a565b509056fe546f6b656e206e6f74206f776e6564206279207468652066726f6d20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373446f6e277420616c6c6f77206275726e206f66204e4654732076696120746869732066756e6374696f6e54524945445f544f5f4d494e545f4e4f4e5f46554e4749424c455f464f525f46554e4749424c455f544f4b454e4f574e4552535f414e445f4944535f4d5553545f484156455f53414d455f4c454e47544854524945445f544f5f4d494e545f46554e4749424c455f464f525f4e4f4e5f46554e4749424c455f544f4b454ea26469706673582212204d99782d76c09d8507bb8f3029826a22522ee166311d9a6a491dd8d2a7784db864736f6c63430007050033
[ 38 ]
0xF3BB497A33b0644E6692c4d68A4b936eF7Dfb49D
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /** * @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; } } /** * @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 Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin 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 {} } /** * @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); } } /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } /** * @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); } } } } /** * @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"); } } } // 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 safeTransferNative(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: Native_TRANSFER_FAILED'); } } /** * @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)); } } /** * @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); } } contract StakingPool is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; EnumerableSet.AddressSet private _governors; struct UserInfo { uint256 amount; uint256 rewardDebt; uint256 lockAmount; uint256 releaseAmount; } struct PoolInfo { IERC20 lpToken; IERC20 rewardToken; uint256 timeStart; uint256 timeEnd; // bonus tokens for per second. uint256 bonusPerSecond; uint256 lockedSeconds; //after exit stake ,need lock time uint256 lpAmount; uint256 lastRewardTime; uint256 accBonusPerShare; uint256 lpTokenType; //0 indicate normal token, 1 is xtoken IERC20 lpTokenFrom; bool open; //pool status } // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; struct WithdrawOrder { uint256 orderTime; uint256 amount; } mapping(uint256 => mapping(address => WithdrawOrder[])) public userWithdrawInfo; event Deposit(address indexed user, uint256 indexed pid, address token, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, address token, uint256 amount); event WithdrawUnlock(address indexed user, uint256 indexed pid, address token, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event GovernorAdded( address _user); event GovernorDeleted( address _user); bytes32 constant public STAKINGPOOL_CALL_HASH_TYPE = keccak256("withdrawExit(address receiver,uint256 pid,uint256 exitAmount)"); /** * @dev Constructor. */ constructor(){ } function poolLength() external view returns (uint256) { return poolInfo.length; } function getLockLength(uint256 _pid, address _user) public view returns (uint256) { return userWithdrawInfo[_pid][_user].length; } // Add a new staking pool to the pool. Can only be called by the owner. function add( IERC20 _lpToken,IERC20 _rewardToken, uint256 _timeStart, uint256 _timeEnd , uint256 _bonusPerSecond,uint256 _lockedSeconds, uint256 _lpTokenType, IERC20 _lpTokenFrom , bool _open) public onlyGovernor { require( _timeStart > block.timestamp && _timeEnd > _timeStart, "invalid time limit"); poolInfo.push(PoolInfo({ lpToken : _lpToken, rewardToken : _rewardToken, timeStart : _timeStart, timeEnd : _timeEnd, bonusPerSecond : _bonusPerSecond, lockedSeconds : _lockedSeconds, lpAmount : 0, lastRewardTime : _timeStart, accBonusPerShare :0, lpTokenType :_lpTokenType, lpTokenFrom : _lpTokenFrom, open : _open })); //need transfer staking bonus token uint256 _amount = _timeEnd.sub(_timeStart).mul(_bonusPerSecond); TransferHelper.safeTransferFrom( address(_rewardToken), msg.sender, address(this), _amount); } // set staking pool info, only can adjust time where pool is not start harvest. function setPoolInfo( uint256 _pid, uint256 _timeStart, uint256 _timeEnd , uint256 _bonusPerSecond,uint256 _lockedSeconds, uint256 _lpTokenType, IERC20 _lpTokenFrom , bool _open) public onlyGovernor { require( _timeStart > block.timestamp && _timeEnd > _timeStart, "invalid time limit"); PoolInfo storage pool = poolInfo[_pid]; require( pool.timeStart > block.timestamp, "staking is enabled"); require( block.timestamp < pool.timeStart, "pool is mining"); //reward token uint256 _newAmount = _timeEnd.sub(_timeStart).mul(_bonusPerSecond); uint256 _amount = pool.timeEnd.sub(pool.timeStart).mul(pool.bonusPerSecond); if( _newAmount > _amount){ TransferHelper.safeTransferFrom( address(pool.rewardToken), msg.sender, address(this), _newAmount.sub(_amount)); } else if( _newAmount < _amount){ TransferHelper.safeTransfer( address(pool.rewardToken), msg.sender , _amount.sub(_newAmount) ); } pool.timeStart = _timeStart; pool.lastRewardTime = _timeStart; pool.timeEnd = _timeEnd; pool.bonusPerSecond = _bonusPerSecond; pool.lockedSeconds = _lockedSeconds; pool.lpTokenType = _lpTokenType; pool.lpTokenFrom = _lpTokenFrom; pool.open = _open; } //update pool status function setPoolStatus( uint256 _pid, bool _open) public onlyGovernor { PoolInfo storage pool = poolInfo[_pid]; pool.open = _open; } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; uint256 number = block.timestamp ; if (number <= pool.lastRewardTime) { return; } if( pool.lastRewardTime >= pool.timeEnd){ return; } //set the end time if( number >= pool.timeEnd ){ number = pool.timeEnd; } uint256 lpSupply = pool.lpAmount; if (lpSupply == 0) { pool.lastRewardTime = number; return; } uint256 multiplier = number.sub(pool.lastRewardTime); uint256 bonusReward = multiplier.mul(pool.bonusPerSecond); pool.accBonusPerShare = pool.accBonusPerShare.add(bonusReward.mul(1e12).div(lpSupply)); pool.lastRewardTime = number; } function pending(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accBonusPerShare = pool.accBonusPerShare; uint256 lpSupply = pool.lpAmount; uint256 number = block.timestamp; if( number <= pool.timeStart ){ return 0; } if( number > pool.timeEnd ){ number = pool.timeEnd; } if (number > pool.lastRewardTime && lpSupply != 0) { uint256 multiplier = number.sub(pool.lastRewardTime); uint256 bonusReward = multiplier.mul(pool.bonusPerSecond) ; accBonusPerShare = accBonusPerShare.add(bonusReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accBonusPerShare).div(1e12).sub(user.rewardDebt); } // Deposit LP tokens dividends bonus; function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; require( pool.open == true , "pool is closed!"); UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pendingAmount = user.amount.mul(pool.accBonusPerShare).div(1e12).sub(user.rewardDebt); if (pendingAmount > 0) { TransferHelper.safeTransfer( address(pool.rewardToken), msg.sender , pendingAmount ); } } if (_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); pool.lpAmount = pool.lpAmount.add(_amount); } user.rewardDebt = user.amount.mul(pool.accBonusPerShare).div(1e12); emit Deposit(msg.sender, _pid, address(pool.lpToken), _amount); } // Withdraw LP tokens. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pendingAmount = user.amount.mul(pool.accBonusPerShare).div(1e12).sub(user.rewardDebt); if (pendingAmount > 0) { TransferHelper.safeTransfer( address(pool.rewardToken), msg.sender , pendingAmount ); } if (_amount > 0 ) { if( pool.lockedSeconds == 0 ){ user.amount = user.amount.sub(_amount); pool.lpAmount = pool.lpAmount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } else{ user.lockAmount = user.lockAmount.add(_amount); userWithdrawInfo[_pid][msg.sender].push(WithdrawOrder({orderTime: block.timestamp, amount: _amount})); } } user.rewardDebt = user.amount.mul(pool.accBonusPerShare).div(1e12); emit Withdraw(msg.sender, _pid, address(pool.lpToken), _amount); } //unlock lp token function pendingUnlock(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 unlockAmount = 0; uint256 checkTime = block.timestamp; if( user.lockAmount > 0 && pool.lockedSeconds > 0){ WithdrawOrder[] memory orders = userWithdrawInfo[_pid][_user]; uint256 len = orders.length; for (uint256 i = 0; i < len; i++) { if( orders[i].orderTime.add(pool.lockedSeconds) <= checkTime ){ unlockAmount = unlockAmount.add( orders[i].amount); } else{ break;//withdraw orders sorted by ordertime asc } } } return unlockAmount; } //withdraw unlock lp function withdrawUnlock(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(pool.lockedSeconds > 0 , "invalid pool"); updatePool(_pid); uint256 unlockAmount = 0; uint256 checkTime = block.timestamp; uint256 index = 0; if( user.lockAmount > 0 && pool.lockedSeconds > 0){ WithdrawOrder[] memory orders = userWithdrawInfo[_pid][msg.sender]; uint256 len = orders.length; if( len > 0 ){ index = len ; for (uint256 i = 0; i < len; i++) { if( orders[i].orderTime.add(pool.lockedSeconds) <= checkTime ){ unlockAmount = unlockAmount.add( orders[i].amount); } else{ index = i; break; } } //pop some orders for (uint256 i = 0; i < len - index; i++) { userWithdrawInfo[_pid][msg.sender][i] = userWithdrawInfo[_pid][msg.sender][i + index]; } for (uint256 j = len -index; j < len ; j++) { userWithdrawInfo[_pid][msg.sender].pop(); } } } uint256 pendingAmount = user.amount.mul(pool.accBonusPerShare).div(1e12).sub(user.rewardDebt); if (pendingAmount > 0) { TransferHelper.safeTransfer( address(pool.rewardToken), msg.sender , pendingAmount ); } if (unlockAmount > 0 ) { user.amount = user.amount.sub(unlockAmount); user.lockAmount = user.lockAmount.sub(unlockAmount); user.releaseAmount = user.releaseAmount.add( unlockAmount ); pool.lpAmount = pool.lpAmount.sub(unlockAmount); pool.lpToken.safeTransfer(address(msg.sender), unlockAmount); } user.rewardDebt = user.amount.mul(pool.accBonusPerShare).div(1e12); emit WithdrawUnlock(msg.sender, _pid, address(pool.lpToken), unlockAmount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 amount = user.amount; if( amount > 0 && pool.lockedSeconds == 0 ){ user.amount = 0; user.rewardDebt = 0; pool.lpToken.safeTransfer(address(msg.sender), amount); } emit EmergencyWithdraw(msg.sender, _pid, amount); } //emergency withdraw function withdrawEmergency(address tokenaddress,address to) public onlyOwner{ TransferHelper.safeTransfer( tokenaddress, to , IERC20(tokenaddress).balanceOf(address(this))); } function withdrawEmergencyNative(address to , uint256 amount) public onlyOwner{ TransferHelper.safeTransferNative(to, amount); } //governor function addGovernor(address _governor) public onlyOwner returns (bool) { require(_governor != address(0), "_governor is the zero address"); emit GovernorAdded( _governor ); return EnumerableSet.add(_governors, _governor); } function delGovernor(address _governor) public onlyOwner returns (bool) { require(_governor != address(0), "_governor is the zero address"); emit GovernorDeleted( _governor ); return EnumerableSet.remove(_governors, _governor); } function getGovernorLength() public view returns (uint256) { return EnumerableSet.length(_governors); } function isGovernor(address account) public view returns (bool) { return EnumerableSet.contains(_governors, account); } function getGovernor(uint256 _index) public view returns (address){ require(_index <= getGovernorLength() - 1, "index out of bounds"); return EnumerableSet.at(_governors, _index); } // modifier for governor function modifier onlyGovernor() { require(isGovernor(msg.sender) || owner() == msg.sender , "caller is not the governor"); _; } }
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c8063715018a6116100de578063c10ad32011610097578063e4c75c2711610071578063e4c75c271461049d578063eb4a2200146104cd578063eb65fa70146104eb578063f2fde38b1461051c5761018e565b8063c10ad32014610435578063e2bbb15814610451578063e43581b81461046d5761018e565b8063715018a6146103865780638da5cb5b146103905780638ee3f9d3146103ae57806393f1a40b146103ca57806393f26a4c146103fd578063bbcaf3fe146104195761018e565b80634b8270dd1161014b57806351eb05a61161012557806351eb05a6146103025780635312ea8e1461031e5780635f030e201461033a57806360f12836146103565761018e565b80634b8270dd146102985780634c19af35146102b65780634dd7a167146102d25761018e565b8063081e3eda146101935780631526fe27146101b1578063175c71d2146101ec5780632eff9de21461021c5780633c4a25d01461024c578063441a3e701461027c575b600080fd5b61019b610538565b6040516101a89190614292565b60405180910390f35b6101cb60048036038101906101c69190613870565b610545565b6040516101e39c9b9a99989796959493929190613ef6565b60405180910390f35b61020660048036038101906102019190613870565b610622565b6040516102139190613e45565b60405180910390f35b610236600480360381019061023191906138c2565b61068c565b6040516102439190614292565b60405180910390f35b610266600480360381019061026191906136e0565b6106ea565b6040516102739190613ec0565b60405180910390f35b61029660048036038101906102919190613989565b610821565b005b6102a0610bb9565b6040516102ad9190614292565b60405180910390f35b6102d060048036038101906102cb9190613745565b610bca565b005b6102ec60048036038101906102e791906136e0565b610c54565b6040516102f99190613ec0565b60405180910390f35b61031c60048036038101906103179190613870565b610d8b565b005b61033860048036038101906103339190613870565b610eca565b005b610354600480360381019061034f91906137aa565b611045565b005b610370600480360381019061036b91906138c2565b611366565b60405161037d9190614292565b60405180910390f35b61038e6115e1565b005b610398611669565b6040516103a59190613e45565b60405180910390f35b6103c860048036038101906103c391906139c5565b611692565b005b6103e460048036038101906103df91906138c2565b6119d6565b6040516103f494939291906142d6565b60405180910390f35b61041760048036038101906104129190613709565b611a13565b005b610433600480360381019061042e919061394d565b611b26565b005b61044f600480360381019061044a9190613870565b611c18565b005b61046b60048036038101906104669190613989565b61234c565b005b610487600480360381019061048291906136e0565b61262f565b6040516104949190613ec0565b60405180910390f35b6104b760048036038101906104b291906138c2565b612643565b6040516104c49190614292565b60405180910390f35b6104d561280a565b6040516104e29190613edb565b60405180910390f35b610505600480360381019061050091906138fe565b61282e565b6040516105139291906142ad565b60405180910390f35b610536600480360381019061053191906136e0565b61287c565b005b6000600380549050905090565b6003818154811061055557600080fd5b90600052602060002090600b02016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600201549080600301549080600401549080600501549080600601549080600701549080600801549080600901549080600a0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169080600a0160149054906101000a900460ff1690508c565b6000600161062e610bb9565b610638919061442e565b82111561067a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067190614252565b60405180910390fd5b610685600183612974565b9050919050565b60006005600084815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050905092915050565b60006106f461298e565b73ffffffffffffffffffffffffffffffffffffffff16610712611669565b73ffffffffffffffffffffffffffffffffffffffff1614610768576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075f90614152565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156107d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107cf90614172565b60405180910390fd5b7fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b5826040516108079190613e45565b60405180910390a161081a600183612996565b9050919050565b60006003838154811061085d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b0201905060006004600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508281600001541015610908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ff906141d2565b60405180910390fd5b61091184610d8b565b600061095b826001015461094d64e8d4a5100061093f876008015487600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b612a9990919063ffffffff16565b90506000811115610996576109958360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163383612af2565b5b6000841115610b0357600083600501541415610a3e576109c3848360000154612a9990919063ffffffff16565b82600001819055506109e2848460060154612a9990919063ffffffff16565b8360060181905550610a3933858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612c289092919063ffffffff16565b610b02565b610a55848360020154612cae90919063ffffffff16565b82600201819055506005600086815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405280428152602001868152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550505b5b610b3564e8d4a51000610b27856008015485600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b8260010181905550843373ffffffffffffffffffffffffffffffffffffffff167f457f950b75085c30ff780acd57bde642ff1316cc4aad9f286af2c1ffc4163a788560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1687604051610baa929190613e97565b60405180910390a35050505050565b6000610bc56001612d0c565b905090565b610bd261298e565b73ffffffffffffffffffffffffffffffffffffffff16610bf0611669565b73ffffffffffffffffffffffffffffffffffffffff1614610c46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3d90614152565b60405180910390fd5b610c508282612d21565b5050565b6000610c5e61298e565b73ffffffffffffffffffffffffffffffffffffffff16610c7c611669565b73ffffffffffffffffffffffffffffffffffffffff1614610cd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc990614152565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3990614172565b60405180910390fd5b7fdfb04b8bae328825d688a202cf30ce1289a05ff288e4c6423074a0e3fc3a657082604051610d719190613e45565b60405180910390a1610d84600183612e47565b9050919050565b600060038281548110610dc7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b02019050600042905081600701548111610dee575050610ec7565b8160030154826007015410610e04575050610ec7565b81600301548110610e1757816003015490505b6000826006015490506000811415610e3a57818360070181905550505050610ec7565b6000610e53846007015484612a9990919063ffffffff16565b90506000610e6e8560040154836129c690919063ffffffff16565b9050610eb0610e9d84610e8f64e8d4a51000856129c690919063ffffffff16565b612a4190919063ffffffff16565b8660080154612cae90919063ffffffff16565b856008018190555083856007018190555050505050505b50565b600060038281548110610f06577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b0201905060006004600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050600081600001549050600081118015610f87575060008360050154145b15610ff0576000826000018190555060008260010181905550610fef33828560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612c289092919063ffffffff16565b5b833373ffffffffffffffffffffffffffffffffffffffff167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae0595836040516110379190614292565b60405180910390a350505050565b61104e3361262f565b8061108b57503373ffffffffffffffffffffffffffffffffffffffff16611073611669565b73ffffffffffffffffffffffffffffffffffffffff16145b6110ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110c190614092565b60405180910390fd5b42871180156110d857508686115b611117576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161110e90614192565b60405180910390fd5b60036040518061018001604052808b73ffffffffffffffffffffffffffffffffffffffff1681526020018a73ffffffffffffffffffffffffffffffffffffffff16815260200189815260200188815260200187815260200186815260200160008152602001898152602001600081526020018581526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183151581525090806001815401808255809150506001900390600052602060002090600b020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e082015181600701556101008201518160080155610120820151816009015561014082015181600a0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061016082015181600a0160146101000a81548160ff0219169083151502179055505050600061134c8661133e8a8a612a9990919063ffffffff16565b6129c690919063ffffffff16565b905061135a89333084612e77565b50505050505050505050565b600080600384815481106113a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b0201905060006004600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008042905060008360020154118015611425575060008460050154115b156115d45760006005600089815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156114e25783829060005260206000209060020201604051806040016040529081600082015481526020016001820154815250508152602001906001019061149c565b50505050905060008151905060005b818110156115d05783611555886005015485848151811061153b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160000151612cae90919063ffffffff16565b116115b8576115b1838281518110611596577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516020015186612cae90919063ffffffff16565b94506115bd565b6115d0565b80806115c89061451d565b9150506114f1565b5050505b8194505050505092915050565b6115e961298e565b73ffffffffffffffffffffffffffffffffffffffff16611607611669565b73ffffffffffffffffffffffffffffffffffffffff161461165d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165490614152565b60405180910390fd5b6116676000612fb0565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61169b3361262f565b806116d857503373ffffffffffffffffffffffffffffffffffffffff166116c0611669565b73ffffffffffffffffffffffffffffffffffffffff16145b611717576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170e90614092565b60405180910390fd5b428711801561172557508686115b611764576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175b90614192565b60405180910390fd5b6000600389815481106117a0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b02019050428160020154116117f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ed90614012565b60405180910390fd5b8060020154421061183c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183390614032565b60405180910390fd5b6000611863876118558b8b612a9990919063ffffffff16565b6129c690919063ffffffff16565b90506000611898836004015461188a85600201548660030154612a9990919063ffffffff16565b6129c690919063ffffffff16565b9050808211156118e9576118e48360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633306118df8587612a9990919063ffffffff16565b612e77565b611934565b80821015611933576119328360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163361192d8585612a9990919063ffffffff16565b612af2565b5b5b8983600201819055508983600701819055508883600301819055508783600401819055508683600501819055508583600901819055508483600a0160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508383600a0160146101000a81548160ff0219169083151502179055505050505050505050505050565b6004602052816000526040600020602052806000526040600020600091509150508060000154908060010154908060020154908060030154905084565b611a1b61298e565b73ffffffffffffffffffffffffffffffffffffffff16611a39611669565b73ffffffffffffffffffffffffffffffffffffffff1614611a8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a8690614152565b60405180910390fd5b611b2282828473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611acd9190613e45565b60206040518083038186803b158015611ae557600080fd5b505afa158015611af9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1d9190613899565b612af2565b5050565b611b2f3361262f565b80611b6c57503373ffffffffffffffffffffffffffffffffffffffff16611b54611669565b73ffffffffffffffffffffffffffffffffffffffff16145b611bab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ba290614092565b60405180910390fd5b600060038381548110611be7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b020190508181600a0160146101000a81548160ff021916908315150217905550505050565b600060038281548110611c54577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b0201905060006004600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506000826005015411611cff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cf690614272565b60405180910390fd5b611d0883610d8b565b6000804290506000808460020154118015611d27575060008560050154115b1561213a5760006005600088815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611de457838290600052602060002090600202016040518060400160405290816000820154815260200160018201548152505081526020019060010190611d9e565b50505050905060008151905060008111156121375780925060005b81811015611ee15784611e638960050154858481518110611e49577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015160000151612cae90919063ffffffff16565b11611ec657611ebf838281518110611ea4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516020015187612cae90919063ffffffff16565b9550611ece565b809350611ee1565b8080611ed99061451d565b915050611dff565b5060005b8382611ef1919061442e565b81101561205957600560008a815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208482611f54919061434d565b81548110611f8b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060020201600560008b815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110612021577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000209060020201600082015481600001556001820154816001015590505080806120519061451d565b915050611ee5565b5060008382612068919061442e565b90505b8181101561213557600560008a815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054806120f9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000209060020201600080820160009055600182016000905550509055808061212d9061451d565b91505061206b565b505b50505b6000612184856001015461217664e8d4a510006121688a600801548a600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b612a9990919063ffffffff16565b905060008111156121bf576121be8660010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163383612af2565b5b6000841115612294576121df848660000154612a9990919063ffffffff16565b85600001819055506121fe848660020154612a9990919063ffffffff16565b856002018190555061221d848660030154612cae90919063ffffffff16565b856003018190555061223c848760060154612a9990919063ffffffff16565b866006018190555061229333858860000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612c289092919063ffffffff16565b5b6122c664e8d4a510006122b8886008015488600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b8560010181905550863373ffffffffffffffffffffffffffffffffffffffff167fec466d4ad909a588e82ea2df26dd14252103de7e1ac984742169477de12cd9338860000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168760405161233b929190613e97565b60405180910390a350505050505050565b600060038381548110612388577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b020190506001151581600a0160149054906101000a900460ff161515146123f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123e790614112565b60405180910390fd5b60006004600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061244d84610d8b565b6000816000015411156124e15760006124a4826001015461249664e8d4a51000612488876008015487600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b612a9990919063ffffffff16565b905060008111156124df576124de8360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff163383612af2565b5b505b600083111561257a5761253b3330858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16613074909392919063ffffffff16565b612552838260000154612cae90919063ffffffff16565b8160000181905550612571838360060154612cae90919063ffffffff16565b82600601819055505b6125ac64e8d4a5100061259e846008015484600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b8160010181905550833373ffffffffffffffffffffffffffffffffffffffff167fd2f8022f659fd9c8c558f30c00fd5ee7038f7cb56da45095c3e0e7d48b3e0c4b8460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1686604051612621929190613e97565b60405180910390a350505050565b600061263c6001836130fd565b9050919050565b60008060038481548110612680577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090600b0201905060006004600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008260080154905060008360060154905060004290508460020154811161271457600095505050505050612804565b846003015481111561272857846003015490505b84600701548111801561273c575060008214155b156127b857600061275a866007015483612a9990919063ffffffff16565b905060006127758760040154836129c690919063ffffffff16565b90506127b36127a48561279664e8d4a51000856129c690919063ffffffff16565b612a4190919063ffffffff16565b86612cae90919063ffffffff16565b945050505b6127fc84600101546127ee64e8d4a510006127e08789600001546129c690919063ffffffff16565b612a4190919063ffffffff16565b612a9990919063ffffffff16565b955050505050505b92915050565b7fa1f7366573db6f0b9c1eb6f2c3199f67ade40c247d2dd4b1299799560ab0cd6a81565b6005602052826000526040600020602052816000526040600020818154811061285657600080fd5b906000526020600020906002020160009250925050508060000154908060010154905082565b61288461298e565b73ffffffffffffffffffffffffffffffffffffffff166128a2611669565b73ffffffffffffffffffffffffffffffffffffffff16146128f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128ef90614152565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612968576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161295f90614052565b60405180910390fd5b61297181612fb0565b50565b6000612983836000018361312d565b60001c905092915050565b600033905090565b60006129be836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6131c7565b905092915050565b6000808314156129d95760009050612a3b565b600082846129e791906143d4565b90508284826129f691906143a3565b14612a36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2d90614132565b60405180910390fd5b809150505b92915050565b6000808211612a85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a7c906140f2565b60405180910390fd5b8183612a9191906143a3565b905092915050565b600082821115612ade576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ad5906140b2565b60405180910390fd5b8183612aea919061442e565b905092915050565b6000808473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401612b24929190613e97565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051612b729190613e2e565b6000604051808303816000865af19150503d8060008114612baf576040519150601f19603f3d011682016040523d82523d6000602084013e612bb4565b606091505b5091509150818015612be25750600081511480612be1575080806020019051810190612be09190613781565b5b5b612c21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c1890613ff2565b60405180910390fd5b5050505050565b612ca98363a9059cbb60e01b8484604051602401612c47929190613e97565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613237565b505050565b6000808284612cbd919061434d565b905083811015612d02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cf990614072565b60405180910390fd5b8091505092915050565b6000612d1a826000016132fe565b9050919050565b60008273ffffffffffffffffffffffffffffffffffffffff1682600067ffffffffffffffff811115612d7c577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612dae5781602001600182028036833780820191505090505b50604051612dbc9190613e2e565b60006040518083038185875af1925050503d8060008114612df9576040519150601f19603f3d011682016040523d82523d6000602084013e612dfe565b606091505b5050905080612e42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e3990614212565b60405180910390fd5b505050565b6000612e6f836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61330f565b905092915050565b6000808573ffffffffffffffffffffffffffffffffffffffff166323b872dd868686604051602401612eab93929190613e60565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051612ef99190613e2e565b6000604051808303816000865af19150503d8060008114612f36576040519150601f19603f3d011682016040523d82523d6000602084013e612f3b565b606091505b5091509150818015612f695750600081511480612f68575080806020019051810190612f679190613781565b5b5b612fa8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f9f90614232565b60405180910390fd5b505050505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6130f7846323b872dd60e01b85858560405160240161309593929190613e60565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613237565b50505050565b6000613125836000018373ffffffffffffffffffffffffffffffffffffffff1660001b613499565b905092915050565b600081836000018054905011613178576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161316f90613fd2565b60405180910390fd5b8260000182815481106131b4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200154905092915050565b60006131d38383613499565b61322c578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050613231565b600090505b92915050565b6000613299826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166134bc9092919063ffffffff16565b90506000815111156132f957808060200190518101906132b99190613781565b6132f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016132ef906141f2565b60405180910390fd5b5b505050565b600081600001805490509050919050565b6000808360010160008481526020019081526020016000205490506000811461348d576000600182613341919061442e565b9050600060018660000180549050613359919061442e565b90506000866000018281548110613399577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050808760000184815481106133e3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055506001836133fe919061434d565b8760010160008381526020019081526020016000208190555086600001805480613451577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050613493565b60009150505b92915050565b600080836001016000848152602001908152602001600020541415905092915050565b60606134cb84846000856134d4565b90509392505050565b606082471015613519576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613510906140d2565b60405180910390fd5b613522856135e8565b613561576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613558906141b2565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161358a9190613e2e565b60006040518083038185875af1925050503d80600081146135c7576040519150601f19603f3d011682016040523d82523d6000602084013e6135cc565b606091505b50915091506135dc8282866135fb565b92505050949350505050565b600080823b905060008111915050919050565b6060831561360b5782905061365b565b60008351111561361e5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016136529190613fb0565b60405180910390fd5b9392505050565b60008135905061367181614a65565b92915050565b60008135905061368681614a7c565b92915050565b60008151905061369b81614a7c565b92915050565b6000813590506136b081614a93565b92915050565b6000813590506136c581614aaa565b92915050565b6000815190506136da81614aaa565b92915050565b6000602082840312156136f257600080fd5b600061370084828501613662565b91505092915050565b6000806040838503121561371c57600080fd5b600061372a85828601613662565b925050602061373b85828601613662565b9150509250929050565b6000806040838503121561375857600080fd5b600061376685828601613662565b9250506020613777858286016136b6565b9150509250929050565b60006020828403121561379357600080fd5b60006137a18482850161368c565b91505092915050565b60008060008060008060008060006101208a8c0312156137c957600080fd5b60006137d78c828d016136a1565b99505060206137e88c828d016136a1565b98505060406137f98c828d016136b6565b975050606061380a8c828d016136b6565b965050608061381b8c828d016136b6565b95505060a061382c8c828d016136b6565b94505060c061383d8c828d016136b6565b93505060e061384e8c828d016136a1565b9250506101006138608c828d01613677565b9150509295985092959850929598565b60006020828403121561388257600080fd5b6000613890848285016136b6565b91505092915050565b6000602082840312156138ab57600080fd5b60006138b9848285016136cb565b91505092915050565b600080604083850312156138d557600080fd5b60006138e3858286016136b6565b92505060206138f485828601613662565b9150509250929050565b60008060006060848603121561391357600080fd5b6000613921868287016136b6565b935050602061393286828701613662565b9250506040613943868287016136b6565b9150509250925092565b6000806040838503121561396057600080fd5b600061396e858286016136b6565b925050602061397f85828601613677565b9150509250929050565b6000806040838503121561399c57600080fd5b60006139aa858286016136b6565b92505060206139bb858286016136b6565b9150509250929050565b600080600080600080600080610100898b0312156139e257600080fd5b60006139f08b828c016136b6565b9850506020613a018b828c016136b6565b9750506040613a128b828c016136b6565b9650506060613a238b828c016136b6565b9550506080613a348b828c016136b6565b94505060a0613a458b828c016136b6565b93505060c0613a568b828c016136a1565b92505060e0613a678b828c01613677565b9150509295985092959890939650565b613a8081614462565b82525050565b613a8f81614474565b82525050565b613a9e81614480565b82525050565b6000613aaf8261431b565b613ab98185614331565b9350613ac98185602086016144ea565b80840191505092915050565b613ade816144c6565b82525050565b6000613aef82614326565b613af9818561433c565b9350613b098185602086016144ea565b613b12816145c4565b840191505092915050565b6000613b2a60228361433c565b9150613b35826145d5565b604082019050919050565b6000613b4d601f8361433c565b9150613b5882614624565b602082019050919050565b6000613b7060128361433c565b9150613b7b8261464d565b602082019050919050565b6000613b93600e8361433c565b9150613b9e82614676565b602082019050919050565b6000613bb660268361433c565b9150613bc18261469f565b604082019050919050565b6000613bd9601b8361433c565b9150613be4826146ee565b602082019050919050565b6000613bfc601a8361433c565b9150613c0782614717565b602082019050919050565b6000613c1f601e8361433c565b9150613c2a82614740565b602082019050919050565b6000613c4260268361433c565b9150613c4d82614769565b604082019050919050565b6000613c65601a8361433c565b9150613c70826147b8565b602082019050919050565b6000613c88600f8361433c565b9150613c93826147e1565b602082019050919050565b6000613cab60218361433c565b9150613cb68261480a565b604082019050919050565b6000613cce60208361433c565b9150613cd982614859565b602082019050919050565b6000613cf1601d8361433c565b9150613cfc82614882565b602082019050919050565b6000613d1460128361433c565b9150613d1f826148ab565b602082019050919050565b6000613d37601d8361433c565b9150613d42826148d4565b602082019050919050565b6000613d5a60128361433c565b9150613d65826148fd565b602082019050919050565b6000613d7d602a8361433c565b9150613d8882614926565b604082019050919050565b6000613da060268361433c565b9150613dab82614975565b604082019050919050565b6000613dc360248361433c565b9150613dce826149c4565b604082019050919050565b6000613de660138361433c565b9150613df182614a13565b602082019050919050565b6000613e09600c8361433c565b9150613e1482614a3c565b602082019050919050565b613e28816144bc565b82525050565b6000613e3a8284613aa4565b915081905092915050565b6000602082019050613e5a6000830184613a77565b92915050565b6000606082019050613e756000830186613a77565b613e826020830185613a77565b613e8f6040830184613e1f565b949350505050565b6000604082019050613eac6000830185613a77565b613eb96020830184613e1f565b9392505050565b6000602082019050613ed56000830184613a86565b92915050565b6000602082019050613ef06000830184613a95565b92915050565b600061018082019050613f0c600083018f613ad5565b613f19602083018e613ad5565b613f26604083018d613e1f565b613f33606083018c613e1f565b613f40608083018b613e1f565b613f4d60a083018a613e1f565b613f5a60c0830189613e1f565b613f6760e0830188613e1f565b613f75610100830187613e1f565b613f83610120830186613e1f565b613f91610140830185613ad5565b613f9f610160830184613a86565b9d9c50505050505050505050505050565b60006020820190508181036000830152613fca8184613ae4565b905092915050565b60006020820190508181036000830152613feb81613b1d565b9050919050565b6000602082019050818103600083015261400b81613b40565b9050919050565b6000602082019050818103600083015261402b81613b63565b9050919050565b6000602082019050818103600083015261404b81613b86565b9050919050565b6000602082019050818103600083015261406b81613ba9565b9050919050565b6000602082019050818103600083015261408b81613bcc565b9050919050565b600060208201905081810360008301526140ab81613bef565b9050919050565b600060208201905081810360008301526140cb81613c12565b9050919050565b600060208201905081810360008301526140eb81613c35565b9050919050565b6000602082019050818103600083015261410b81613c58565b9050919050565b6000602082019050818103600083015261412b81613c7b565b9050919050565b6000602082019050818103600083015261414b81613c9e565b9050919050565b6000602082019050818103600083015261416b81613cc1565b9050919050565b6000602082019050818103600083015261418b81613ce4565b9050919050565b600060208201905081810360008301526141ab81613d07565b9050919050565b600060208201905081810360008301526141cb81613d2a565b9050919050565b600060208201905081810360008301526141eb81613d4d565b9050919050565b6000602082019050818103600083015261420b81613d70565b9050919050565b6000602082019050818103600083015261422b81613d93565b9050919050565b6000602082019050818103600083015261424b81613db6565b9050919050565b6000602082019050818103600083015261426b81613dd9565b9050919050565b6000602082019050818103600083015261428b81613dfc565b9050919050565b60006020820190506142a76000830184613e1f565b92915050565b60006040820190506142c26000830185613e1f565b6142cf6020830184613e1f565b9392505050565b60006080820190506142eb6000830187613e1f565b6142f86020830186613e1f565b6143056040830185613e1f565b6143126060830184613e1f565b95945050505050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000614358826144bc565b9150614363836144bc565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561439857614397614566565b5b828201905092915050565b60006143ae826144bc565b91506143b9836144bc565b9250826143c9576143c8614595565b5b828204905092915050565b60006143df826144bc565b91506143ea836144bc565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561442357614422614566565b5b828202905092915050565b6000614439826144bc565b9150614444836144bc565b92508282101561445757614456614566565b5b828203905092915050565b600061446d8261449c565b9050919050565b60008115159050919050565b6000819050919050565b600061449582614462565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006144d1826144d8565b9050919050565b60006144e38261449c565b9050919050565b60005b838110156145085780820151818401526020810190506144ed565b83811115614517576000848401525b50505050565b6000614528826144bc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561455b5761455a614566565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b7f5472616e7366657248656c7065723a205452414e534645525f4641494c454400600082015250565b7f7374616b696e6720697320656e61626c65640000000000000000000000000000600082015250565b7f706f6f6c206973206d696e696e67000000000000000000000000000000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f63616c6c6572206973206e6f742074686520676f7665726e6f72000000000000600082015250565b7f536166654d6174683a207375627472616374696f6e206f766572666c6f770000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206469766973696f6e206279207a65726f000000000000600082015250565b7f706f6f6c20697320636c6f736564210000000000000000000000000000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5f676f7665726e6f7220697320746865207a65726f2061646472657373000000600082015250565b7f696e76616c69642074696d65206c696d69740000000000000000000000000000600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f77697468647261773a206e6f7420676f6f640000000000000000000000000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5472616e7366657248656c7065723a204e61746976655f5452414e534645525f60008201527f4641494c45440000000000000000000000000000000000000000000000000000602082015250565b7f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f464160008201527f494c454400000000000000000000000000000000000000000000000000000000602082015250565b7f696e646578206f7574206f6620626f756e647300000000000000000000000000600082015250565b7f696e76616c696420706f6f6c0000000000000000000000000000000000000000600082015250565b614a6e81614462565b8114614a7957600080fd5b50565b614a8581614474565b8114614a9057600080fd5b50565b614a9c8161448a565b8114614aa757600080fd5b50565b614ab3816144bc565b8114614abe57600080fd5b5056fea2646970667358221220f1fb71f8c1ecb4f8024c874df4e966e351760af791e53797d7d870b69ac64c7d64736f6c63430008040033
[ 7 ]
0xf3BB5ef0f8f6705Fb5614aF4f3E191aDc9EdD324
// Sources flattened with hardhat v2.6.4 https://hardhat.org // File @openzeppelin/contracts/utils/introspection/[email protected] // 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/ERC721/[email protected] 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/[email protected] 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/[email protected] 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/[email protected] 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/[email protected] 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/[email protected] 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/[email protected] 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/[email protected] pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File @openzeppelin/contracts/token/ERC721/extensions/[email protected] 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/[email protected] 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/security/[email protected] 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; } } // File @openzeppelin/contracts/access/[email protected] 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 base64-sol/[email protected] /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides a function for encoding some bytes in base64 library Base64 { string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } } // File @openzeppelin/contracts/interfaces/[email protected] pragma solidity ^0.8.0; // File @openzeppelin/contracts/interfaces/[email protected] pragma solidity ^0.8.0; /** * @dev Interface for the NFT Royalty Standard */ interface IERC2981 is IERC165 { /** * @dev Called with the sale price to determine how much royalty is owed and to whom. * @param tokenId - the NFT asset queried for royalty information * @param salePrice - the sale price of the NFT asset specified by `tokenId` * @return receiver - address of who should be sent the royalty payment * @return royaltyAmount - the royalty payment amount for `salePrice` */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); } // File contracts/drip.sol pragma solidity ^0.8.0; contract Drip is ERC721Enumerable, IERC2981, ReentrancyGuard, Ownable { uint256 public PRESALE_PRICE = 35000000000000000; // 0.035 eth uint256 public FULL_PRICE = 50000000000000000; // 0.05 ETH uint public WIDTH = 16; uint public HEIGHT = 18; uint256 public SIZE = WIDTH * HEIGHT; uint internal NEXT_TOKEN_ID = 0; // Allow for starting/pausing sale bool public MINT_ENABLED = false; bool public PRESALE_ENABLED = false; // Royalty, in basis points uint internal ROYALTY_BPS = 1000; // sell 50 @ 0.035 ETH // sell 238 @ 0.05 ETH uint internal NUM_PRESALE = 50; string internal BASE_TOKEN_URI; constructor(string memory baseURI) ERC721("Drip", "DRIP") Ownable() { BASE_TOKEN_URI = baseURI; } function setBaseURI(string memory baseURI) public onlyOwner { BASE_TOKEN_URI = baseURI; } // ERC2891 royalty function, for ERC2891-compatible platforms function royaltyInfo(uint256, uint256 _salePrice) override external view returns ( address receiver, uint256 royaltyAmount ) { return (owner(), (_salePrice * ROYALTY_BPS) / 10000); } // Update royalty rate, but unable to rug (> 30%) function updateRoyaltyBPS(uint8 newRoyaltyBPS) public onlyOwner { require(newRoyaltyBPS <= 3000, "No royalty greater than 30%"); ROYALTY_BPS = newRoyaltyBPS; } function getX(uint256 tokenId) public view returns (uint256) { // X coordinate return tokenId % WIDTH; } function getY(uint tokenId) public view returns (uint) { // Y coordinate return tokenId / WIDTH; } function tokenURI(uint256 tokenId) override public view returns (string memory) { string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Drip #', toString(tokenId), ': (', toString(getX(tokenId)), ', ', toString(getY(tokenId)), ')", "attributes": [{"trait_type": "X", "display_type": "number", "value": ', toString(getX(tokenId)), '}, {"trait_type": "Y", "display_type": "number", "value": ', toString(getY(tokenId)), '}], "description": "DripDAO is community powered merch.", "image": "', BASE_TOKEN_URI, toString(tokenId), '.svg"}')))); string memory output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } function mint() public payable nonReentrant { require(MINT_ENABLED || PRESALE_ENABLED, "Minting is not currently enabled right now"); require(balanceOf(msg.sender) < 10, "Cannot mint more than 10 per address"); if (PRESALE_ENABLED && !MINT_ENABLED) { // Presale enabled, full sale not enabled yet // Only a certain amt can be minted require(NEXT_TOKEN_ID < NUM_PRESALE, "No more presale minting available"); require(PRESALE_PRICE <= msg.value, "Must send 0.035 ETH for mint"); } else if (MINT_ENABLED) { // Full sale now enabled // Yeehaw // If 50 still havent been minted yet, keep the prices at PRESALE_PRICE require(NEXT_TOKEN_ID < SIZE, "No more minting available"); if (NEXT_TOKEN_ID < NUM_PRESALE) { require(PRESALE_PRICE <= msg.value, "Must send 0.035 ETH for mint"); } else { require(FULL_PRICE <= msg.value, "Must send 0.05 ETH for mint"); } } _safeMint(msg.sender, NEXT_TOKEN_ID++); } function tokensOfOwner(address _owner) external view returns(uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // 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 startPresale() public onlyOwner { require(!MINT_ENABLED, "Cannot start presale while full sale is in effect"); PRESALE_ENABLED = true; } function endPresale() public onlyOwner { PRESALE_ENABLED = false; } function startMint() public onlyOwner { require(!PRESALE_ENABLED, "Cannot start full sale while presale is in effect"); MINT_ENABLED = true; } function endMint() public onlyOwner { MINT_ENABLED = false; } function withdrawAll() external onlyOwner { // This forwards all available gas. Be sure to check the return value! (bool success, ) = msg.sender.call{value: address(this).balance}(""); require(success, "Transfer failed."); } }
0x6080604052600436106102255760003560e01c806370a0823111610123578063a22cb465116100ab578063d44d33941161006f578063d44d3394146107d7578063e985e9c514610802578063eef5deb11461083f578063f2fde38b14610868578063f8821a3b1461089157610225565b8063a22cb46514610706578063a43be57b1461072f578063b88d4fde14610746578063bdffd2821461076f578063c87b56dd1461079a57610225565b8063853828b6116100f2578063853828b6146106315780638da5cb5b146106485780638e5cb5f61461067357806395d89b41146106b05780639fbca28c146106db57610225565b806370a0823114610563578063715018a6146105a0578063845a4697146105b75780638462151c146105f457610225565b806323b872dd116101b15780634f6ccce7116101755780634f6ccce71461046a57806355f804b3146104a757806362dc6e21146104d05780636352211e146104fb57806369ea80d51461053857610225565b806323b872dd146103865780632a55205a146103af5780632be09561146103ed5780632f745c591461040457806342842e0e1461044157610225565b8063081812fc116101f8578063081812fc146102c0578063095ea7b3146102fd5780630b40cc99146103265780631249c58b1461035157806318160ddd1461035b57610225565b8063017043a51461022a57806301ffc9a71461024157806304c98b2b1461027e57806306fdde0314610295575b600080fd5b34801561023657600080fd5b5061023f6108bc565b005b34801561024d57600080fd5b50610268600480360381019061026391906134e0565b610955565b60405161027591906145f4565b60405180910390f35b34801561028a57600080fd5b506102936109cf565b005b3480156102a157600080fd5b506102aa610ab8565b6040516102b7919061460f565b60405180910390f35b3480156102cc57600080fd5b506102e760048036038101906102e29190613573565b610b4a565b6040516102f49190614542565b60405180910390f35b34801561030957600080fd5b50610324600480360381019061031f91906134a4565b610bcf565b005b34801561033257600080fd5b5061033b610ce7565b60405161034891906149b1565b60405180910390f35b610359610ced565b005b34801561036757600080fd5b50610370610fcd565b60405161037d91906149b1565b60405180910390f35b34801561039257600080fd5b506103ad60048036038101906103a8919061339e565b610fda565b005b3480156103bb57600080fd5b506103d660048036038101906103d1919061359c565b61103a565b6040516103e49291906145a9565b60405180910390f35b3480156103f957600080fd5b5061040261106b565b005b34801561041057600080fd5b5061042b600480360381019061042691906134a4565b611154565b60405161043891906149b1565b60405180910390f35b34801561044d57600080fd5b506104686004803603810190610463919061339e565b6111f9565b005b34801561047657600080fd5b50610491600480360381019061048c9190613573565b611219565b60405161049e91906149b1565b60405180910390f35b3480156104b357600080fd5b506104ce60048036038101906104c99190613532565b6112b0565b005b3480156104dc57600080fd5b506104e5611346565b6040516104f291906149b1565b60405180910390f35b34801561050757600080fd5b50610522600480360381019061051d9190613573565b61134c565b60405161052f9190614542565b60405180910390f35b34801561054457600080fd5b5061054d6113fe565b60405161055a91906149b1565b60405180910390f35b34801561056f57600080fd5b5061058a60048036038101906105859190613339565b611404565b60405161059791906149b1565b60405180910390f35b3480156105ac57600080fd5b506105b56114bc565b005b3480156105c357600080fd5b506105de60048036038101906105d99190613573565b611544565b6040516105eb91906149b1565b60405180910390f35b34801561060057600080fd5b5061061b60048036038101906106169190613339565b61155b565b60405161062891906145d2565b60405180910390f35b34801561063d57600080fd5b506106466116d7565b005b34801561065457600080fd5b5061065d611802565b60405161066a9190614542565b60405180910390f35b34801561067f57600080fd5b5061069a60048036038101906106959190613573565b61182c565b6040516106a791906149b1565b60405180910390f35b3480156106bc57600080fd5b506106c5611843565b6040516106d2919061460f565b60405180910390f35b3480156106e757600080fd5b506106f06118d5565b6040516106fd91906145f4565b60405180910390f35b34801561071257600080fd5b5061072d60048036038101906107289190613468565b6118e8565b005b34801561073b57600080fd5b50610744611a69565b005b34801561075257600080fd5b5061076d600480360381019061076891906133ed565b611b02565b005b34801561077b57600080fd5b50610784611b64565b60405161079191906149b1565b60405180910390f35b3480156107a657600080fd5b506107c160048036038101906107bc9190613573565b611b6a565b6040516107ce919061460f565b60405180910390f35b3480156107e357600080fd5b506107ec611c23565b6040516107f991906149b1565b60405180910390f35b34801561080e57600080fd5b5061082960048036038101906108249190613362565b611c29565b60405161083691906145f4565b60405180910390f35b34801561084b57600080fd5b50610866600480360381019061086191906135d8565b611cbd565b005b34801561087457600080fd5b5061088f600480360381019061088a9190613339565b611d8e565b005b34801561089d57600080fd5b506108a6611e86565b6040516108b391906145f4565b60405180910390f35b6108c4611e99565b73ffffffffffffffffffffffffffffffffffffffff166108e2611802565b73ffffffffffffffffffffffffffffffffffffffff1614610938576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092f90614811565b60405180910390fd5b6000601260006101000a81548160ff021916908315150217905550565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109c857506109c782611ea1565b5b9050919050565b6109d7611e99565b73ffffffffffffffffffffffffffffffffffffffff166109f5611802565b73ffffffffffffffffffffffffffffffffffffffff1614610a4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4290614811565b60405180910390fd5b601260009054906101000a900460ff1615610a9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9290614951565b60405180910390fd5b6001601260016101000a81548160ff021916908315150217905550565b606060008054610ac790614cd1565b80601f0160208091040260200160405190810160405280929190818152602001828054610af390614cd1565b8015610b405780601f10610b1557610100808354040283529160200191610b40565b820191906000526020600020905b815481529060010190602001808311610b2357829003601f168201915b5050505050905090565b6000610b5582611f83565b610b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8b906147f1565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610bda8261134c565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4290614871565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c6a611e99565b73ffffffffffffffffffffffffffffffffffffffff161480610c995750610c9881610c93611e99565b611c29565b5b610cd8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ccf90614771565b60405180910390fd5b610ce28383611fef565b505050565b600d5481565b6002600a541415610d33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2a90614971565b60405180910390fd5b6002600a81905550601260009054906101000a900460ff1680610d625750601260019054906101000a900460ff165b610da1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9890614731565b60405180910390fd5b600a610dac33611404565b10610dec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de390614991565b60405180910390fd5b601260019054906101000a900460ff168015610e155750601260009054906101000a900460ff16155b15610eaa5760145460115410610e60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e57906148d1565b60405180910390fd5b34600c541115610ea5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9c90614931565b60405180910390fd5b610fa3565b601260009054906101000a900460ff1615610fa25760105460115410610f05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610efc906146d1565b60405180910390fd5b6014546011541015610f5b5734600c541115610f56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4d90614931565b60405180910390fd5b610fa1565b34600d541115610fa0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9790614671565b60405180910390fd5b5b5b5b610fc33360116000815480929190610fba90614d03565b919050556120a8565b6001600a81905550565b6000600880549050905090565b610feb610fe5611e99565b826120c6565b61102a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611021906148b1565b60405180910390fd5b6110358383836121a4565b505050565b600080611045611802565b612710601354856110569190614b80565b6110609190614b4f565b915091509250929050565b611073611e99565b73ffffffffffffffffffffffffffffffffffffffff16611091611802565b73ffffffffffffffffffffffffffffffffffffffff16146110e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110de90614811565b60405180910390fd5b601260019054906101000a900460ff1615611137576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112e90614911565b60405180910390fd5b6001601260006101000a81548160ff021916908315150217905550565b600061115f83611404565b82106111a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119790614631565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61121483838360405180602001604052806000815250611b02565b505050565b6000611223610fcd565b8210611264576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125b906148f1565b60405180910390fd5b6008828154811061129e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b6112b8611e99565b73ffffffffffffffffffffffffffffffffffffffff166112d6611802565b73ffffffffffffffffffffffffffffffffffffffff161461132c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132390614811565b60405180910390fd5b8060159080519060200190611342929190613148565b5050565b600c5481565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ec906147b1565b60405180910390fd5b80915050919050565b600f5481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611475576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146c90614791565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6114c4611e99565b73ffffffffffffffffffffffffffffffffffffffff166114e2611802565b73ffffffffffffffffffffffffffffffffffffffff1614611538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152f90614811565b60405180910390fd5b6115426000612400565b565b6000600e54826115549190614b4f565b9050919050565b6060600061156883611404565b905060008114156115eb57600067ffffffffffffffff8111156115b4577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156115e25781602001602082028036833780820191505090505b509150506116d2565b60008167ffffffffffffffff81111561162d577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561165b5781602001602082028036833780820191505090505b50905060005b828110156116cb576116738582611154565b8282815181106116ac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080806116c390614d03565b915050611661565b8193505050505b919050565b6116df611e99565b73ffffffffffffffffffffffffffffffffffffffff166116fd611802565b73ffffffffffffffffffffffffffffffffffffffff1614611753576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174a90614811565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff16476040516117799061447b565b60006040518083038185875af1925050503d80600081146117b6576040519150601f19603f3d011682016040523d82523d6000602084013e6117bb565b606091505b50509050806117ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f690614891565b60405180910390fd5b50565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600e548261183c9190614d4c565b9050919050565b60606001805461185290614cd1565b80601f016020809104026020016040519081016040528092919081815260200182805461187e90614cd1565b80156118cb5780601f106118a0576101008083540402835291602001916118cb565b820191906000526020600020905b8154815290600101906020018083116118ae57829003601f168201915b5050505050905090565b601260009054906101000a900460ff1681565b6118f0611e99565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561195e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161195590614711565b60405180910390fd5b806005600061196b611e99565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611a18611e99565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611a5d91906145f4565b60405180910390a35050565b611a71611e99565b73ffffffffffffffffffffffffffffffffffffffff16611a8f611802565b73ffffffffffffffffffffffffffffffffffffffff1614611ae5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611adc90614811565b60405180910390fd5b6000601260016101000a81548160ff021916908315150217905550565b611b13611b0d611e99565b836120c6565b611b52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b49906148b1565b60405180910390fd5b611b5e848484846124c6565b50505050565b60105481565b60606000611bf3611b7a84612522565b611b8b611b868661182c565b612522565b611b9c611b9787611544565b612522565b611bad611ba88861182c565b612522565b611bbe611bb989611544565b612522565b6015611bc98a612522565b604051602001611bdf9796959493929190614490565b6040516020818303038152906040526126cf565b9050600081604051602001611c089190614459565b60405160208183030381529060405290508092505050919050565b600e5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611cc5611e99565b73ffffffffffffffffffffffffffffffffffffffff16611ce3611802565b73ffffffffffffffffffffffffffffffffffffffff1614611d39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d3090614811565b60405180910390fd5b610bb88160ff161115611d81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7890614851565b60405180910390fd5b8060ff1660138190555050565b611d96611e99565b73ffffffffffffffffffffffffffffffffffffffff16611db4611802565b73ffffffffffffffffffffffffffffffffffffffff1614611e0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0190614811565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611e7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e7190614691565b60405180910390fd5b611e8381612400565b50565b601260019054906101000a900460ff1681565b600033905090565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611f6c57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611f7c5750611f7b8261287a565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166120628361134c565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6120c28282604051806020016040528060008152506128e4565b5050565b60006120d182611f83565b612110576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161210790614751565b60405180910390fd5b600061211b8361134c565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061218a57508373ffffffffffffffffffffffffffffffffffffffff1661217284610b4a565b73ffffffffffffffffffffffffffffffffffffffff16145b8061219b575061219a8185611c29565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166121c48261134c565b73ffffffffffffffffffffffffffffffffffffffff161461221a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221190614831565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561228a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612281906146f1565b60405180910390fd5b61229583838361293f565b6122a0600082611fef565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122f09190614bda565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546123479190614af9565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6124d18484846121a4565b6124dd84848484612a53565b61251c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161251390614651565b60405180910390fd5b50505050565b6060600082141561256a576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506126ca565b600082905060005b6000821461259c57808061258590614d03565b915050600a826125959190614b4f565b9150612572565b60008167ffffffffffffffff8111156125de577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156126105781602001600182028036833780820191505090505b5090505b600085146126c3576001826126299190614bda565b9150600a856126389190614d4c565b60306126449190614af9565b60f81b818381518110612680577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856126bc9190614b4f565b9450612614565b8093505050505b919050565b60606000825114156126f257604051806020016040528060008152509050612875565b6000604051806060016040528060408152602001614ebe60409139905060006003600285516127219190614af9565b61272b9190614b4f565b60046127379190614b80565b905060006020826127489190614af9565b67ffffffffffffffff811115612787577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156127b95781602001600182028036833780820191505090505b509050818152600183018586518101602084015b81831015612834576003830192508251603f8160121c1685015160f81b8252600182019150603f81600c1c1685015160f81b8252600182019150603f8160061c1685015160f81b8252600182019150603f811685015160f81b8252600182019150506127cd565b60038951066001811461284e576002811461285e57612869565b613d3d60f01b6002830352612869565b603d60f81b60018303525b50505050508093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6128ee8383612bea565b6128fb6000848484612a53565b61293a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161293190614651565b60405180910390fd5b505050565b61294a838383612db8565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561298d5761298881612dbd565b6129cc565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146129cb576129ca8382612e06565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a0f57612a0a81612f73565b612a4e565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612a4d57612a4c82826130b6565b5b5b505050565b6000612a748473ffffffffffffffffffffffffffffffffffffffff16613135565b15612bdd578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612a9d611e99565b8786866040518563ffffffff1660e01b8152600401612abf949392919061455d565b602060405180830381600087803b158015612ad957600080fd5b505af1925050508015612b0a57506040513d601f19601f82011682018060405250810190612b079190613509565b60015b612b8d573d8060008114612b3a576040519150601f19603f3d011682016040523d82523d6000602084013e612b3f565b606091505b50600081511415612b85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b7c90614651565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612be2565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c51906147d1565b60405180910390fd5b612c6381611f83565b15612ca3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c9a906146b1565b60405180910390fd5b612caf6000838361293f565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612cff9190614af9565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612e1384611404565b612e1d9190614bda565b9050600060076000848152602001908152602001600020549050818114612f02576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612f879190614bda565b9050600060096000848152602001908152602001600020549050600060088381548110612fdd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110613025577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001819055508160096000838152602001908152602001600020819055506009600085815260200190815260200160002060009055600880548061309a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006130c183611404565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600080823b905060008111915050919050565b82805461315490614cd1565b90600052602060002090601f01602090048101928261317657600085556131bd565b82601f1061318f57805160ff19168380011785556131bd565b828001600101855582156131bd579182015b828111156131bc5782518255916020019190600101906131a1565b5b5090506131ca91906131ce565b5090565b5b808211156131e75760008160009055506001016131cf565b5090565b60006131fe6131f9846149fd565b6149cc565b90508281526020810184848401111561321657600080fd5b613221848285614c8f565b509392505050565b600061323c61323784614a2d565b6149cc565b90508281526020810184848401111561325457600080fd5b61325f848285614c8f565b509392505050565b60008135905061327681614e4a565b92915050565b60008135905061328b81614e61565b92915050565b6000813590506132a081614e78565b92915050565b6000815190506132b581614e78565b92915050565b600082601f8301126132cc57600080fd5b81356132dc8482602086016131eb565b91505092915050565b600082601f8301126132f657600080fd5b8135613306848260208601613229565b91505092915050565b60008135905061331e81614e8f565b92915050565b60008135905061333381614ea6565b92915050565b60006020828403121561334b57600080fd5b600061335984828501613267565b91505092915050565b6000806040838503121561337557600080fd5b600061338385828601613267565b925050602061339485828601613267565b9150509250929050565b6000806000606084860312156133b357600080fd5b60006133c186828701613267565b93505060206133d286828701613267565b92505060406133e38682870161330f565b9150509250925092565b6000806000806080858703121561340357600080fd5b600061341187828801613267565b945050602061342287828801613267565b93505060406134338782880161330f565b925050606085013567ffffffffffffffff81111561345057600080fd5b61345c878288016132bb565b91505092959194509250565b6000806040838503121561347b57600080fd5b600061348985828601613267565b925050602061349a8582860161327c565b9150509250929050565b600080604083850312156134b757600080fd5b60006134c585828601613267565b92505060206134d68582860161330f565b9150509250929050565b6000602082840312156134f257600080fd5b600061350084828501613291565b91505092915050565b60006020828403121561351b57600080fd5b6000613529848285016132a6565b91505092915050565b60006020828403121561354457600080fd5b600082013567ffffffffffffffff81111561355e57600080fd5b61356a848285016132e5565b91505092915050565b60006020828403121561358557600080fd5b60006135938482850161330f565b91505092915050565b600080604083850312156135af57600080fd5b60006135bd8582860161330f565b92505060206135ce8582860161330f565b9150509250929050565b6000602082840312156135ea57600080fd5b60006135f884828501613324565b91505092915050565b600061360d838361443b565b60208301905092915050565b61362281614c0e565b82525050565b600061363382614a82565b61363d8185614ab0565b935061364883614a5d565b8060005b838110156136795781516136608882613601565b975061366b83614aa3565b92505060018101905061364c565b5085935050505092915050565b61368f81614c20565b82525050565b60006136a082614a8d565b6136aa8185614ac1565b93506136ba818560208601614c9e565b6136c381614e39565b840191505092915050565b60006136d982614a98565b6136e38185614add565b93506136f3818560208601614c9e565b6136fc81614e39565b840191505092915050565b600061371282614a98565b61371c8185614aee565b935061372c818560208601614c9e565b80840191505092915050565b6000815461374581614cd1565b61374f8186614aee565b9450600182166000811461376a576001811461377b576137ae565b60ff198316865281860193506137ae565b61378485614a6d565b60005b838110156137a657815481890152600182019150602081019050613787565b838801955050505b50505092915050565b60006137c4603a83614aee565b91507f7d2c207b2274726169745f74797065223a202259222c2022646973706c61795f60008301527f74797065223a20226e756d626572222c202276616c7565223a200000000000006020830152603a82019050919050565b600061382a604a83614aee565b91507f29222c202261747472696275746573223a205b7b2274726169745f747970652260008301527f3a202258222c2022646973706c61795f74797065223a20226e756d626572222c60208301527f202276616c7565223a20000000000000000000000000000000000000000000006040830152604a82019050919050565b60006138b6602b83614add565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b600061391c603283614add565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b6000613982601b83614add565b91507f4d7573742073656e6420302e30352045544820666f72206d696e7400000000006000830152602082019050919050565b60006139c2600383614aee565b91507f3a202800000000000000000000000000000000000000000000000000000000006000830152600382019050919050565b6000613a02602683614add565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613a68601c83614add565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000613aa8601983614add565b91507f4e6f206d6f7265206d696e74696e6720617661696c61626c65000000000000006000830152602082019050919050565b6000613ae8602483614add565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613b4e601983614add565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000613b8e602a83614add565b91507f4d696e74696e67206973206e6f742063757272656e746c7920656e61626c656460008301527f207269676874206e6f77000000000000000000000000000000000000000000006020830152604082019050919050565b6000613bf4602c83614add565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613c5a603883614add565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000613cc0602a83614add565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000613d26602983614add565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613d8c602083614add565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000613dcc602c83614add565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613e32602083614add565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613e72602983614add565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613ed8601b83614add565b91507f4e6f20726f79616c74792067726561746572207468616e2033302500000000006000830152602082019050919050565b6000613f18600683614aee565b91507f2e737667227d00000000000000000000000000000000000000000000000000006000830152600682019050919050565b6000613f58604483614aee565b91507f7d5d2c20226465736372697074696f6e223a20224472697044414f206973206360008301527f6f6d6d756e69747920706f7765726564206d657263682e222c2022696d61676560208301527f223a2022000000000000000000000000000000000000000000000000000000006040830152604482019050919050565b6000613fe4602183614add565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061404a600283614aee565b91507f2c200000000000000000000000000000000000000000000000000000000000006000830152600282019050919050565b600061408a601d83614aee565b91507f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000006000830152601d82019050919050565b60006140ca600083614ad2565b9150600082019050919050565b60006140e4601083614add565b91507f5472616e73666572206661696c65642e000000000000000000000000000000006000830152602082019050919050565b6000614124603183614add565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b600061418a602183614add565b91507f4e6f206d6f72652070726573616c65206d696e74696e6720617661696c61626c60008301527f65000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006141f0602c83614add565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6000614256601083614aee565b91507f7b226e616d65223a2022447269702023000000000000000000000000000000006000830152601082019050919050565b6000614296603183614add565b91507f43616e6e6f742073746172742066756c6c2073616c65207768696c652070726560008301527f73616c6520697320696e206566666563740000000000000000000000000000006020830152604082019050919050565b60006142fc601c83614add565b91507f4d7573742073656e6420302e3033352045544820666f72206d696e74000000006000830152602082019050919050565b600061433c603183614add565b91507f43616e6e6f742073746172742070726573616c65207768696c652066756c6c2060008301527f73616c6520697320696e206566666563740000000000000000000000000000006020830152604082019050919050565b60006143a2601f83614add565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b60006143e2602483614add565b91507f43616e6e6f74206d696e74206d6f7265207468616e203130207065722061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b61444481614c78565b82525050565b61445381614c78565b82525050565b60006144648261407d565b91506144708284613707565b915081905092915050565b6000614486826140bd565b9150819050919050565b600061449b82614249565b91506144a7828a613707565b91506144b2826139b5565b91506144be8289613707565b91506144c98261403d565b91506144d58288613707565b91506144e08261381d565b91506144ec8287613707565b91506144f7826137b7565b91506145038286613707565b915061450e82613f4b565b915061451a8285613738565b91506145268284613707565b915061453182613f0b565b915081905098975050505050505050565b60006020820190506145576000830184613619565b92915050565b60006080820190506145726000830187613619565b61457f6020830186613619565b61458c604083018561444a565b818103606083015261459e8184613695565b905095945050505050565b60006040820190506145be6000830185613619565b6145cb602083018461444a565b9392505050565b600060208201905081810360008301526145ec8184613628565b905092915050565b60006020820190506146096000830184613686565b92915050565b6000602082019050818103600083015261462981846136ce565b905092915050565b6000602082019050818103600083015261464a816138a9565b9050919050565b6000602082019050818103600083015261466a8161390f565b9050919050565b6000602082019050818103600083015261468a81613975565b9050919050565b600060208201905081810360008301526146aa816139f5565b9050919050565b600060208201905081810360008301526146ca81613a5b565b9050919050565b600060208201905081810360008301526146ea81613a9b565b9050919050565b6000602082019050818103600083015261470a81613adb565b9050919050565b6000602082019050818103600083015261472a81613b41565b9050919050565b6000602082019050818103600083015261474a81613b81565b9050919050565b6000602082019050818103600083015261476a81613be7565b9050919050565b6000602082019050818103600083015261478a81613c4d565b9050919050565b600060208201905081810360008301526147aa81613cb3565b9050919050565b600060208201905081810360008301526147ca81613d19565b9050919050565b600060208201905081810360008301526147ea81613d7f565b9050919050565b6000602082019050818103600083015261480a81613dbf565b9050919050565b6000602082019050818103600083015261482a81613e25565b9050919050565b6000602082019050818103600083015261484a81613e65565b9050919050565b6000602082019050818103600083015261486a81613ecb565b9050919050565b6000602082019050818103600083015261488a81613fd7565b9050919050565b600060208201905081810360008301526148aa816140d7565b9050919050565b600060208201905081810360008301526148ca81614117565b9050919050565b600060208201905081810360008301526148ea8161417d565b9050919050565b6000602082019050818103600083015261490a816141e3565b9050919050565b6000602082019050818103600083015261492a81614289565b9050919050565b6000602082019050818103600083015261494a816142ef565b9050919050565b6000602082019050818103600083015261496a8161432f565b9050919050565b6000602082019050818103600083015261498a81614395565b9050919050565b600060208201905081810360008301526149aa816143d5565b9050919050565b60006020820190506149c6600083018461444a565b92915050565b6000604051905081810181811067ffffffffffffffff821117156149f3576149f2614e0a565b5b8060405250919050565b600067ffffffffffffffff821115614a1857614a17614e0a565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115614a4857614a47614e0a565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000614b0482614c78565b9150614b0f83614c78565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614b4457614b43614d7d565b5b828201905092915050565b6000614b5a82614c78565b9150614b6583614c78565b925082614b7557614b74614dac565b5b828204905092915050565b6000614b8b82614c78565b9150614b9683614c78565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614bcf57614bce614d7d565b5b828202905092915050565b6000614be582614c78565b9150614bf083614c78565b925082821015614c0357614c02614d7d565b5b828203905092915050565b6000614c1982614c58565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015614cbc578082015181840152602081019050614ca1565b83811115614ccb576000848401525b50505050565b60006002820490506001821680614ce957607f821691505b60208210811415614cfd57614cfc614ddb565b5b50919050565b6000614d0e82614c78565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614d4157614d40614d7d565b5b600182019050919050565b6000614d5782614c78565b9150614d6283614c78565b925082614d7257614d71614dac565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b614e5381614c0e565b8114614e5e57600080fd5b50565b614e6a81614c20565b8114614e7557600080fd5b50565b614e8181614c2c565b8114614e8c57600080fd5b50565b614e9881614c78565b8114614ea357600080fd5b50565b614eaf81614c82565b8114614eba57600080fd5b5056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212209974d7beb7f3b4a7ccfa5a05581da7ad731640fb919acb1b058bc9b7ee150bca64736f6c63430008000033
[ 5, 3, 4, 19 ]
0xf3bbc02f16862daf56f73cf277973ec4454fe6e3
//SPDX-License-Identifier: MIT pragma solidity ^0.7.0; contract Owned { modifier onlyOwner() { require(msg.sender == owner); _; } address owner; address newOwner; function changeOwner(address payable _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } } contract ERC20 { string public symbol; string public name; uint8 public decimals; uint256 public totalSupply; mapping (address=>uint256) balances; mapping (address=>mapping (address=>uint256)) allowed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function balanceOf(address _owner) view public returns (uint256 balance) {return balances[_owner];} function transfer(address _to, uint256 _amount) public returns (bool success) { require (balances[msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(msg.sender,_to,_amount); return true; } function transferFrom(address _from,address _to,uint256 _amount) public returns (bool success) { require (balances[_from]>=_amount&&allowed[_from][msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[_from]-=_amount; allowed[_from][msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender]=_amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) view public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract PayPalProfessional is Owned,ERC20{ uint256 public maxSupply; constructor(address _owner) { symbol = "PAYPRO"; name = "PayPal Professional"; decimals = 18; totalSupply = 1000000000000000*10**uint256(decimals); maxSupply = 1000000000000000*10**uint256(decimals); owner = _owner; balances[owner] = totalSupply; } receive() external payable { revert(); } }
0x6080604052600436106100ab5760003560e01c806379ba50971161006457806379ba50971461025957806395d89b4114610270578063a6f9dae114610285578063a9059cbb146102b8578063d5abeb01146102f1578063dd62ed3e14610306576100b5565b806306fdde03146100ba578063095ea7b31461014457806318160ddd1461019157806323b872dd146101b8578063313ce567146101fb57806370a0823114610226576100b5565b366100b557600080fd5b600080fd5b3480156100c657600080fd5b506100cf610341565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101095781810151838201526020016100f1565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061017d6004803603604081101561016757600080fd5b506001600160a01b0381351690602001356103cf565b604080519115158252519081900360200190f35b34801561019d57600080fd5b506101a6610435565b60408051918252519081900360200190f35b3480156101c457600080fd5b5061017d600480360360608110156101db57600080fd5b506001600160a01b0381358116916020810135909116906040013561043b565b34801561020757600080fd5b50610210610548565b6040805160ff9092168252519081900360200190f35b34801561023257600080fd5b506101a66004803603602081101561024957600080fd5b50356001600160a01b0316610551565b34801561026557600080fd5b5061026e61056c565b005b34801561027c57600080fd5b506100cf6105a4565b34801561029157600080fd5b5061026e600480360360208110156102a857600080fd5b50356001600160a01b03166105fc565b3480156102c457600080fd5b5061017d600480360360408110156102db57600080fd5b506001600160a01b038135169060200135610635565b3480156102fd57600080fd5b506101a66106f0565b34801561031257600080fd5b506101a66004803603604081101561032957600080fd5b506001600160a01b03813581169160200135166106f6565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103c75780601f1061039c576101008083540402835291602001916103c7565b820191906000526020600020905b8154815290600101906020018083116103aa57829003601f168201915b505050505081565b3360008181526007602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60055481565b6001600160a01b038316600090815260066020526040812054821180159061048657506001600160a01b03841660009081526007602090815260408083203384529091529020548211155b80156104925750600082115b80156104b757506001600160a01b038316600090815260066020526040902054828101115b6104c057600080fd5b6001600160a01b0380851660008181526006602081815260408084208054899003905560078252808420338552825280842080548990039055948816808452918152918490208054870190558351868152935190937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92908290030190a35060019392505050565b60045460ff1681565b6001600160a01b031660009081526006602052604090205490565b6001546001600160a01b03163314156105a257600154600080546001600160a01b0319166001600160a01b039092169190911790555b565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156103c75780601f1061039c576101008083540402835291602001916103c7565b6000546001600160a01b0316331461061357600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526006602052604081205482118015906106545750600082115b801561067957506001600160a01b038316600090815260066020526040902054828101115b61068257600080fd5b336000818152600660209081526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b60085481565b6001600160a01b0391821660009081526007602090815260408083209390941682529190915220549056fea26469706673582212203ea4723f1eb9c48701a6df5e427133a4ac7a9f1c7fa2a190e6cadfd09653edb764736f6c63430007060033
[ 2 ]
0xF3Bbc895E3fEb3056223a4d8E9A1232F249875a6
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC721.sol"; import "./Ownable.sol"; import "./Counters.sol"; import "./CryptoCatsV1Contract.sol"; /** * @title CryptoCatsV1Wrapper contract * @dev Extends ERC721 Non-Fungible Token Standard basic implementation. * based on the V1 wrapper of @author @foobar, but optimised to work with our MarketPlace contract. * @author @cryptotato */ contract CryptoCatsV1Wrapper is Ownable, ERC721 { address payable public catAddress = payable(0x19c320b43744254ebdBcb1F1BD0e2a3dc08E01dc); string private _baseTokenURI; uint256 private _tokenSupply; constructor() ERC721("V1 CryptoCats (Wrapped)", "WCCAT") { _baseTokenURI = "ipfs://QmRKVBdB77hmrbJtbHq44RXDfP52V7u3UP8EzSNT4d2cc5/"; } /** * @dev Accepts an offer from the cats contract and assigns a wrapped token to msg.sender */ function wrap(uint _catId) external payable { // Prereq: owner should call `offerCatForSaleToAddress` with price 0 (or higher if they wish) (bool isForSale, , address seller, uint minPrice, address sellOnlyTo) = CryptoCatsV1Contract(catAddress).catsForSale(_catId); require(isForSale == true); require(seller == msg.sender); require(minPrice == 0); require((sellOnlyTo == address(this)) || (sellOnlyTo == address(0x0))); // Buy the punk CryptoCatsV1Contract(catAddress).buyCat{value: msg.value}(_catId); _tokenSupply +=1; // Mint a wrapped punk _mint(msg.sender, _catId); } /** * @dev Burns the wrapped token and transfers the underlying cat to the owner **/ function unwrap(uint256 _catId) external { require(_isApprovedOrOwner(msg.sender, _catId)); _burn(_catId); _tokenSupply -=1; CryptoCatsV1Contract(catAddress).transfer(msg.sender, _catId); } /** * @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 override returns (string memory) { return _baseTokenURI; } /** * @dev Set a new base token URI */ function setBaseTokenURI(string memory __baseTokenURI) public onlyOwner { _baseTokenURI = __baseTokenURI; } /** * @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) external view virtual returns (bool) { return _exists(tokenId); } /** * @dev Gets the total amount of tokens stored by the contract. * @return uint256 representing the total amount of tokens */ function totalSupply() public view returns (uint256) { return _tokenSupply; } } // SPDX-License-Identifier: MIT 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); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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; 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 "./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 Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./Address.sol"; import "./Context.sol"; import "./Strings.sol"; import "./ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping (uint256 => address) private _owners; // Mapping owner address to token count mapping (address => uint256) private _balances; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @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 || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _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 || ERC721.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 { } } // 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; interface CryptoCatsV1Contract { // Events event CatTransfer(address indexed from, address indexed to, uint catIndex); event CatOffered(uint indexed catIndex, uint minPrice, address indexed toAddress); event CatBought(uint indexed catIndex, uint price, address indexed fromAddress, address indexed toAddress); event CatNoLongerForSale(uint indexed catIndex); event Assign(address indexed to, uint256 catIndex); event Transfer(address indexed from, address indexed to, uint256 value); event ReleaseUpdate(uint256 indexed newCatsAdded, uint256 totalSupply, uint256 catPrice, string newImageHash); event UpdateReleasePrice(uint32 releaseId, uint256 catPrice); event UpdateAttribute(uint indexed attributeNumber, address indexed ownerAddress, bytes32 oldValue, bytes32 newValue); // Read contract function name() external view returns (string memory); function catsForSale(uint id) external view returns (bool isForSale, uint catIndex, address seller, uint minPrice, address sellOnlyTo); function _totalSupply() external view returns (uint); function decimals() external view returns (uint8); function imageHash() external view returns (string memory); function catIndexToAddress(uint id) external view returns (address); function standard() external view returns (string memory); function balanceOf(address) external view returns (uint); function symbol() external view returns (string memory); function catsRemainingToAssign() external view returns (uint); function pendingWithdrawals(address) external view returns (uint); function previousContractAddress() external view returns (address); function currentReleaseCeiling() external view returns (uint); function totalSupplyIsLocked() external view returns (bool); // Write contract function withdraw() external; function buyCat(uint catIndex) external payable; function transfer(address _to, uint _value) external; function offerCatForSaleToAddress(uint catIndex, uint minSalePriceInWei, address toAddress) external; function offerCatForSale(uint catIndex, uint minSalePriceInWei) external; function getCat(uint catIndex) external; function catNoLongerForSale(uint catIndex) external; function lockTotalSupply() external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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); } } } }
0x6080604052600436106101355760003560e01c806370a08231116100ab578063b88d4fde1161006f578063b88d4fde14610352578063c87b56dd14610372578063de0e9a3e14610392578063e985e9c5146103b2578063ea598cb0146103fb578063f2fde38b1461040e57600080fd5b806370a08231146102ca578063715018a6146102ea5780638da5cb5b146102ff57806395d89b411461031d578063a22cb4651461033257600080fd5b806323b872dd116100fd57806323b872dd1461020a57806330176e131461022a5780633d5bc6401461024a57806342842e0e1461026a5780634f558e791461028a5780636352211e146102aa57600080fd5b806301ffc9a71461013a57806306fdde031461016f578063081812fc14610191578063095ea7b3146101c957806318160ddd146101eb575b600080fd5b34801561014657600080fd5b5061015a610155366004611578565b61042e565b60405190151581526020015b60405180910390f35b34801561017b57600080fd5b50610184610480565b60405161016691906115ed565b34801561019d57600080fd5b506101b16101ac366004611600565b610512565b6040516001600160a01b039091168152602001610166565b3480156101d557600080fd5b506101e96101e436600461162e565b6105ac565b005b3480156101f757600080fd5b506009545b604051908152602001610166565b34801561021657600080fd5b506101e961022536600461165a565b6106c2565b34801561023657600080fd5b506101e9610245366004611727565b6106f3565b34801561025657600080fd5b506007546101b1906001600160a01b031681565b34801561027657600080fd5b506101e961028536600461165a565b610734565b34801561029657600080fd5b5061015a6102a5366004611600565b61074f565b3480156102b657600080fd5b506101b16102c5366004611600565b61076e565b3480156102d657600080fd5b506101fc6102e5366004611770565b6107e5565b3480156102f657600080fd5b506101e961086c565b34801561030b57600080fd5b506000546001600160a01b03166101b1565b34801561032957600080fd5b506101846108e0565b34801561033e57600080fd5b506101e961034d36600461179b565b6108ef565b34801561035e57600080fd5b506101e961036d3660046117d4565b6109b4565b34801561037e57600080fd5b5061018461038d366004611600565b6109ec565b34801561039e57600080fd5b506101e96103ad366004611600565b610ac7565b3480156103be57600080fd5b5061015a6103cd366004611854565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b6101e9610409366004611600565b610b62565b34801561041a57600080fd5b506101e9610429366004611770565b610cbc565b60006001600160e01b031982166380ac58cd60e01b148061045f57506001600160e01b03198216635b5e139f60e01b145b8061047a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461048f90611882565b80601f01602080910402602001604051908101604052809291908181526020018280546104bb90611882565b80156105085780601f106104dd57610100808354040283529160200191610508565b820191906000526020600020905b8154815290600101906020018083116104eb57829003601f168201915b5050505050905090565b6000818152600360205260408120546001600160a01b03166105905760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b60006105b78261076e565b9050806001600160a01b0316836001600160a01b031614156106255760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610587565b336001600160a01b0382161480610641575061064181336103cd565b6106b35760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610587565b6106bd8383610da6565b505050565b6106cc3382610e14565b6106e85760405162461bcd60e51b8152600401610587906118bd565b6106bd838383610f0b565b6000546001600160a01b0316331461071d5760405162461bcd60e51b81526004016105879061190e565b80516107309060089060208401906114c6565b5050565b6106bd838383604051806020016040528060008152506109b4565b6000818152600360205260408120546001600160a01b0316151561047a565b6000818152600360205260408120546001600160a01b03168061047a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610587565b60006001600160a01b0382166108505760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610587565b506001600160a01b031660009081526004602052604090205490565b6000546001600160a01b031633146108965760405162461bcd60e51b81526004016105879061190e565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60606002805461048f90611882565b6001600160a01b0382163314156109485760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610587565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6109be3383610e14565b6109da5760405162461bcd60e51b8152600401610587906118bd565b6109e6848484846110ab565b50505050565b6000818152600360205260409020546060906001600160a01b0316610a6b5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610587565b6000610a756110de565b90506000815111610a955760405180602001604052806000815250610ac0565b80610a9f846110ed565b604051602001610ab0929190611943565b6040516020818303038152906040525b9392505050565b610ad13382610e14565b610ada57600080fd5b610ae3816111eb565b600160096000828254610af69190611988565b909155505060075460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb90604401600060405180830381600087803b158015610b4757600080fd5b505af1158015610b5b573d6000803e3d6000fd5b5050505050565b600754604051639d773a1b60e01b8152600481018390526000918291829182916001600160a01b0390911690639d773a1b9060240160a060405180830381865afa158015610bb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd8919061199f565b9450945094505093508315156001151514610bf257600080fd5b6001600160a01b0383163314610c0757600080fd5b8115610c1257600080fd5b6001600160a01b038116301480610c3057506001600160a01b038116155b610c3957600080fd5b600754604051636b9281dd60e11b8152600481018790526001600160a01b039091169063d72503ba9034906024016000604051808303818588803b158015610c8057600080fd5b505af1158015610c94573d6000803e3d6000fd5b5050505050600160096000828254610cac9190611a00565b90915550610b5b90503386611286565b6000546001600160a01b03163314610ce65760405162461bcd60e51b81526004016105879061190e565b6001600160a01b038116610d4b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610587565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610ddb8261076e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600360205260408120546001600160a01b0316610e8d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610587565b6000610e988361076e565b9050806001600160a01b0316846001600160a01b03161480610ed35750836001600160a01b0316610ec884610512565b6001600160a01b0316145b80610f0357506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316610f1e8261076e565b6001600160a01b031614610f865760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610587565b6001600160a01b038216610fe85760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610587565b610ff3600082610da6565b6001600160a01b038316600090815260046020526040812080546001929061101c908490611988565b90915550506001600160a01b038216600090815260046020526040812080546001929061104a908490611a00565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6110b6848484610f0b565b6110c2848484846113c8565b6109e65760405162461bcd60e51b815260040161058790611a18565b60606008805461048f90611882565b6060816111115750506040805180820190915260018152600360fc1b602082015290565b8160005b811561113b578061112581611a6a565b91506111349050600a83611a9b565b9150611115565b60008167ffffffffffffffff8111156111565761115661169b565b6040519080825280601f01601f191660200182016040528015611180576020820181803683370190505b5090505b8415610f0357611195600183611988565b91506111a2600a86611aaf565b6111ad906030611a00565b60f81b8183815181106111c2576111c2611ac3565b60200101906001600160f81b031916908160001a9053506111e4600a86611a9b565b9450611184565b60006111f68261076e565b9050611203600083610da6565b6001600160a01b038116600090815260046020526040812080546001929061122c908490611988565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6001600160a01b0382166112dc5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610587565b6000818152600360205260409020546001600160a01b0316156113415760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610587565b6001600160a01b038216600090815260046020526040812080546001929061136a908490611a00565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160a01b0384163b156114bb57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061140c903390899088908890600401611ad9565b6020604051808303816000875af1925050508015611447575060408051601f3d908101601f1916820190925261144491810190611b16565b60015b6114a1573d808015611475576040519150601f19603f3d011682016040523d82523d6000602084013e61147a565b606091505b5080516114995760405162461bcd60e51b815260040161058790611a18565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610f03565b506001949350505050565b8280546114d290611882565b90600052602060002090601f0160209004810192826114f4576000855561153a565b82601f1061150d57805160ff191683800117855561153a565b8280016001018555821561153a579182015b8281111561153a57825182559160200191906001019061151f565b5061154692915061154a565b5090565b5b80821115611546576000815560010161154b565b6001600160e01b03198116811461157557600080fd5b50565b60006020828403121561158a57600080fd5b8135610ac08161155f565b60005b838110156115b0578181015183820152602001611598565b838111156109e65750506000910152565b600081518084526115d9816020860160208601611595565b601f01601f19169290920160200192915050565b602081526000610ac060208301846115c1565b60006020828403121561161257600080fd5b5035919050565b6001600160a01b038116811461157557600080fd5b6000806040838503121561164157600080fd5b823561164c81611619565b946020939093013593505050565b60008060006060848603121561166f57600080fd5b833561167a81611619565b9250602084013561168a81611619565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156116cc576116cc61169b565b604051601f8501601f19908116603f011681019082821181831017156116f4576116f461169b565b8160405280935085815286868601111561170d57600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561173957600080fd5b813567ffffffffffffffff81111561175057600080fd5b8201601f8101841361176157600080fd5b610f03848235602084016116b1565b60006020828403121561178257600080fd5b8135610ac081611619565b801515811461157557600080fd5b600080604083850312156117ae57600080fd5b82356117b981611619565b915060208301356117c98161178d565b809150509250929050565b600080600080608085870312156117ea57600080fd5b84356117f581611619565b9350602085013561180581611619565b925060408501359150606085013567ffffffffffffffff81111561182857600080fd5b8501601f8101871361183957600080fd5b611848878235602084016116b1565b91505092959194509250565b6000806040838503121561186757600080fd5b823561187281611619565b915060208301356117c981611619565b600181811c9082168061189657607f821691505b602082108114156118b757634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008351611955818460208801611595565b835190830190611969818360208801611595565b01949350505050565b634e487b7160e01b600052601160045260246000fd5b60008282101561199a5761199a611972565b500390565b600080600080600060a086880312156119b757600080fd5b85516119c28161178d565b6020870151604088015191965094506119da81611619565b6060870151608088015191945092506119f281611619565b809150509295509295909350565b60008219821115611a1357611a13611972565b500190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000600019821415611a7e57611a7e611972565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082611aaa57611aaa611a85565b500490565b600082611abe57611abe611a85565b500690565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611b0c908301846115c1565b9695505050505050565b600060208284031215611b2857600080fd5b8151610ac08161155f56fea264697066735822122009bc2997bea43f6e3c31a1490f3879ee816f7fa2a6350e866abf0d5cf5c9ce0764736f6c634300080b0033
[ 5, 17 ]
0xf3bc74f48c3292815fd390cad9fa3dc03cb376c5
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 8888888b. 888 888 888b 888 888 888 // 888 Y88b 888 888 8888b 888 888 888 // 888 888 888 888 88888b 888 888 888 // 888 d88P 88888b. 8888b. 88888b. 888888 .d88b. 88888b.d88b. 888Y88b 888 .d88b. 888888 888 888 888 .d88b. 888d888 888 888 // 8888888P" 888 "88b "88b 888 "88b 888 d88""88b 888 "888 "88b 888 Y88b888 d8P Y8b 888 888 888 888 d88""88b 888P" 888 .88P // 888 888 888 .d888888 888 888 888 888 888 888 888 888 888 Y88888 88888888 888 888 888 888 888 888 888 888888K // 888 888 888 888 888 888 888 Y88b. Y88..88P 888 888 888 888 Y8888 Y8b. Y88b. Y88b 888 d88P Y88..88P 888 888 "88b // 888 888 888 "Y888888 888 888 "Y888 "Y88P" 888 888 888 888 Y888 "Y8888 "Y888 "Y8888888P" "Y88P" 888 888 888 import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract PhantomNetwork{ //PhantomNetwork bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122064631733ab464e7042db63c941d77f60d7c599ada84123956539dba81a8840d964736f6c63430008070033
[ 5 ]
0xf3bcace04ecc0e23dc0133d239c61c6bd47ef408
pragma solidity ^0.4.20; /** * @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); } contract ShortAddressProtection { modifier onlyPayloadSize(uint256 numwords) { assert(msg.data.length >= numwords * 32 + 4); _; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic, ShortAddressProtection { using SafeMath for uint256; mapping(address => uint256) internal 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) onlyPayloadSize(2) 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) onlyPayloadSize(3) 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) onlyPayloadSize(2) public returns (bool) { //require user to set to zero before resetting to nonzero require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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) onlyPayloadSize(2) 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) onlyPayloadSize(2) 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; } } 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; } } /** * @title MintableToken token */ contract MintableToken is Ownable, StandardToken { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; address public saleAgent; modifier canMint() { require(!mintingFinished); _; } modifier onlySaleAgent() { require(msg.sender == saleAgent); _; } function setSaleAgent(address _saleAgent) onlyOwner public { require(_saleAgent != address(0)); saleAgent = _saleAgent; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlySaleAgent canMint public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlySaleAgent canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract Token is MintableToken { string public constant name = "TOKPIE"; string public constant symbol = "TKP"; uint8 public constant decimals = 18; } /** * @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(); } } /** * @title WhitelistedCrowdsale * @dev Crowdsale in which only whitelisted users can contribute. */ contract WhitelistedCrowdsale is Ownable { mapping(address => bool) public whitelist; /** * @dev Reverts if beneficiary is not whitelisted. Can be used when extending this contract. */ modifier isWhitelisted(address _beneficiary) { require(whitelist[_beneficiary]); _; } /** * @dev Adds single address to whitelist. * @param _beneficiary Address to be added to the whitelist */ function addToWhitelist(address _beneficiary) external onlyOwner { whitelist[_beneficiary] = true; } /** * @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing. * @param _beneficiaries Addresses to be added to the whitelist */ function addManyToWhitelist(address[] _beneficiaries) external onlyOwner { for (uint256 i = 0; i < _beneficiaries.length; i++) { whitelist[_beneficiaries[i]] = true; } } } /** * @title FinalizableCrowdsale * @dev Extension of Crowdsale where an owner can do extra work * after finishing. */ contract FinalizableCrowdsale is Pausable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); /** * @dev Must be called after crowdsale ends, to do some extra finalization * work. Calls the contract's finalization function. */ function finalize() onlyOwner public { require(!isFinalized); finalization(); Finalized(); isFinalized = true; } /** * @dev Can be overridden to add finalization logic. The overriding function * should call super.finalization() to ensure the chain of finalization is * executed entirely. */ function finalization() internal; } /** * @title RefundVault * @dev This contract is used for storing funds while a crowdsale * is in progress. Supports refunding the money if crowdsale fails, * and forwarding it if crowdsale is successful. */ contract RefundVault is Ownable { using SafeMath for uint256; enum State {Active, Refunding, Closed} mapping(address => uint256) public deposited; address public wallet; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); /** * @param _wallet Vault address */ function RefundVault(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } /** * @param investor Investor address */ function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; Closed(); wallet.transfer(this.balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; RefundsEnabled(); } /** * @param investor Investor address */ function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } } contract preICO is FinalizableCrowdsale, WhitelistedCrowdsale { Token public token; // May 01, 2018 @ UTC 0:01 uint256 public startDate; // May 14, 2018 @ UTC 23:59 uint256 public endDate; // amount of raised money in wei uint256 public weiRaised; // how many token units a buyer gets per wei uint256 public constant rate = 1920; uint256 public constant softCap = 500 * (1 ether); uint256 public constant hardCap = 1000 * (1 ether); // refund vault used to hold funds while crowdsale is running RefundVault public vault; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); /** * @dev _wallet where collect funds during crowdsale * @dev _startDate should be 1525132860 * @dev _endDate should be 1526342340 * @dev _maxEtherPerInvestor should be 10 ether */ function preICO(address _token, address _wallet, uint256 _startDate, uint256 _endDate) public { require(_token != address(0) && _wallet != address(0)); require(_endDate > _startDate); startDate = _startDate; endDate = _endDate; token = Token(_token); vault = new RefundVault(_wallet); } /** * @dev Investors can claim refunds here if crowdsale is unsuccessful */ function claimRefund() public { require(isFinalized); require(!goalReached()); vault.refund(msg.sender); } /** * @dev Checks whether funding goal was reached. * @return Whether funding goal was reached */ function goalReached() public view returns (bool) { return weiRaised >= softCap; } /** * @dev vault finalization task, called when owner calls finalize() */ function finalization() internal { require(hasEnded()); if (goalReached()) { vault.close(); } else { vault.enableRefunds(); } } // fallback function can be used to buy tokens function() external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) whenNotPaused isWhitelisted(beneficiary) isWhitelisted(msg.sender) public payable { require(beneficiary != address(0)); require(validPurchase()); require(!hasEnded()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = weiAmount.mul(rate); // Minimum contribution level in TKP tokens for each investor = 100 TKP require(tokens >= 100 * (10 ** 18)); // update state weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } // send ether to the fund collection wallet function forwardFunds() internal { vault.deposit.value(msg.value)(msg.sender); } // @return true if the transaction can buy tokens function validPurchase() internal view returns (bool) { return !isFinalized && now >= startDate && msg.value != 0; } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return (now > endDate || weiRaised >= hardCap); } } contract ICO is Pausable, WhitelistedCrowdsale { using SafeMath for uint256; Token public token; // June 01, 2018 @ UTC 0:01 uint256 public startDate; // July 05, 2018 on UTC 23:59 uint256 public endDate; uint256 public hardCap; // amount of raised money in wei uint256 public weiRaised; address public wallet; mapping(address => uint256) public deposited; /** * event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); /** * @dev _wallet where collect funds during crowdsale * @dev _startDate should be 1527811260 * @dev _endDate should be 1530835140 * @dev _maxEtherPerInvestor should be 10 ether * @dev _hardCap should be 8700 ether */ function ICO(address _token, address _wallet, uint256 _startDate, uint256 _endDate, uint256 _hardCap) public { require(_token != address(0) && _wallet != address(0)); require(_endDate > _startDate); require(_hardCap > 0); startDate = _startDate; endDate = _endDate; hardCap = _hardCap; token = Token(_token); wallet = _wallet; } function claimFunds() onlyOwner public { require(hasEnded()); wallet.transfer(this.balance); } function getRate() public view returns (uint256) { if (now < startDate || hasEnded()) return 0; // Period: from June 01, 2018 @ UTC 0:01 to June 7, 2018 @ UTC 23:59; Price: 1 ETH = 1840 TKP if (now >= startDate && now < startDate + 604680) return 1840; // Period: from June 08, 2018 @ UTC 0:00 to June 14, 2018 @ UTC 23:59; Price: 1 ETH = 1760 TKP if (now >= startDate + 604680 && now < startDate + 1209480) return 1760; // Period: from June 15, 2018 @ UTC 0:00 to June 21, 2018 @ UTC 23:59; Price: 1 ETH = 1680 TKP if (now >= startDate + 1209480 && now < startDate + 1814280) return 1680; // Period: from June 22, 2018 @ UTC 0:00 to June 28, 2018 @ UTC 23:59; Price: 1 ETH = 1648 TKP if (now >= startDate + 1814280 && now < startDate + 2419080) return 1648; // Period: from June 29, 2018 @ UTC 0:00 to July 5, 2018 @ UTC 23:59; Price: 1 ETH = 1600 TKP if (now >= startDate + 2419080) return 1600; } // fallback function can be used to buy tokens function() external payable { buyTokens(msg.sender); } // low level token purchase function function buyTokens(address beneficiary) whenNotPaused isWhitelisted(beneficiary) isWhitelisted(msg.sender) public payable { require(beneficiary != address(0)); require(validPurchase()); require(!hasEnded()); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = weiAmount.mul(getRate()); // Minimum contribution level in TKP tokens for each investor = 100 TKP require(tokens >= 100 * (10 ** 18)); // update state weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); } // @return true if the transaction can buy tokens function validPurchase() internal view returns (bool) { return now >= startDate && msg.value != 0; } // @return true if crowdsale event has ended function hasEnded() public view returns (bool) { return (now > endDate || weiRaised >= hardCap); } } contract postICO is Ownable { using SafeMath for uint256; Token public token; address public walletE; address public walletB; address public walletC; address public walletF; address public walletG; // 05.07.18 @ UTC 23:59 uint256 public endICODate; bool public finished = false; uint256 public FTST; // Save complete of transfers (due to schedule) to these wallets mapping(uint8 => bool) completedE; mapping(uint8 => bool) completedBC; uint256 public paymentSizeE; uint256 public paymentSizeB; uint256 public paymentSizeC; /** * @dev _endICODate should be 1530835140 */ function postICO( address _token, address _walletE, address _walletB, address _walletC, address _walletF, address _walletG, uint256 _endICODate ) public { require(_token != address(0)); require(_walletE != address(0)); require(_walletB != address(0)); require(_walletC != address(0)); require(_walletF != address(0)); require(_walletG != address(0)); require(_endICODate >= now); token = Token(_token); endICODate = _endICODate; walletE = _walletE; walletB = _walletB; walletC = _walletC; walletF = _walletF; walletG = _walletG; } function finish() onlyOwner public { require(now > endICODate); require(!finished); require(token.saleAgent() == address(this)); FTST = token.totalSupply().mul(100).div(65); // post ICO token allocation: 35% of final total supply of tokens (FTST) will be distributed to the wallets E, B, C, F, G due to the schedule described below. Where FTST = the number of tokens sold during crowdsale x 100 / 65. // Growth reserve: 21% (4-years lock). Distribute 2.625% of the final total supply of tokens (FTST*2625/100000) 8 (eight) times every half a year during 4 (four) years after the endICODate to the wallet [E]. // hold this tokens on postICO contract paymentSizeE = FTST.mul(2625).div(100000); uint256 tokensE = paymentSizeE.mul(8); token.mint(this, tokensE); // Team: 9.6% (2-years lock). // Distribute 0.25% of final total supply of tokens (FTST*25/10000) 4 (four) times every half a year during 2 (two) years after endICODate to the wallet [B]. // hold this tokens on postICO contract paymentSizeB = FTST.mul(25).div(10000); uint256 tokensB = paymentSizeB.mul(4); token.mint(this, tokensB); // Distribute 2.15% of final total supply of tokens (FTST*215/10000) 4 (four) times every half a year during 2 (two) years after endICODate to the wallet [C]. // hold this tokens on postICO contract paymentSizeC = FTST.mul(215).div(10000); uint256 tokensC = paymentSizeC.mul(4); token.mint(this, tokensC); // Angel investors: 2%. Distribute 2% of final total supply of tokens (FTST*2/100) after endICODate to the wallet [F]. uint256 tokensF = FTST.mul(2).div(100); token.mint(walletF, tokensF); // Referral program 1,3% + Bounty program: 1,1%. Distribute 2,4% of final total supply of tokens (FTST*24/1000) after endICODate to the wallet [G]. uint256 tokensG = FTST.mul(24).div(1000); token.mint(walletG, tokensG); token.finishMinting(); finished = true; } function claimTokensE(uint8 order) onlyOwner public { require(finished); require(order >= 1 && order <= 8); require(!completedE[order]); // On January 03, 2019 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 1) { // Thursday, 3 January 2019 г., 23:59:00 require(now >= endICODate + 15724800); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On July 05, 2019 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 2) { // Friday, 5 July 2019 г., 23:59:00 require(now >= endICODate + 31536000); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On January 03, 2020 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 3) { // Friday, 3 January 2020 г., 23:59:00 require(now >= endICODate + 47260800); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On July 04, 2020 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 4) { // Saturday, 4 July 2020 г., 23:59:00 require(now >= endICODate + 63072000); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On January 02, 2021 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 5) { // Saturday, 2 January 2021 г., 23:59:00 require(now >= endICODate + 78796800); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On July 04, 2021 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 6) { // Sunday, 4 July 2021 г., 23:59:00 require(now >= endICODate + 94608000); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On January 02, 2022 @ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 7) { // Sunday, 2 January 2022 г., 23:59:00 require(now >= endICODate + 110332800); token.transfer(walletE, paymentSizeE); completedE[order] = true; } // On July 04, 2022@ UTC 23:59 = FTST*2625/100000 (2.625% of final total supply of tokens) to the wallet [E]. if (order == 8) { // Monday, 4 July 2022 г., 23:59:00 require(now >= endICODate + 126144000); token.transfer(walletE, paymentSizeE); completedE[order] = true; } } function claimTokensBC(uint8 order) onlyOwner public { require(finished); require(order >= 1 && order <= 4); require(!completedBC[order]); // On January 03, 2019 @ UTC 23:59 = FTST*25/10000 (0.25% of final total supply of tokens) to the wallet [B] and FTST*215/10000 (2.15% of final total supply of tokens) to the wallet [C]. if (order == 1) { // Thursday, 3 January 2019 г., 23:59:00 require(now >= endICODate + 15724800); token.transfer(walletB, paymentSizeB); token.transfer(walletC, paymentSizeC); completedBC[order] = true; } // On July 05, 2019 @ UTC 23:59 = FTST*25/10000 (0.25% of final total supply of tokens) to the wallet [B] and FTST*215/10000 (2.15% of final total supply of tokens) to the wallet [C]. if (order == 2) { // Friday, 5 July 2019 г., 23:59:00 require(now >= endICODate + 31536000); token.transfer(walletB, paymentSizeB); token.transfer(walletC, paymentSizeC); completedBC[order] = true; } // On January 03, 2020 @ UTC 23:59 = FTST*25/10000 (0.25% of final total supply of tokens) to the wallet [B] and FTST*215/10000 (2.15% of final total supply of tokens) to the wallet [C]. if (order == 3) { // Friday, 3 January 2020 г., 23:59:00 require(now >= endICODate + 47260800); token.transfer(walletB, paymentSizeB); token.transfer(walletC, paymentSizeC); completedBC[order] = true; } // On July 04, 2020 @ UTC 23:59 = FTST*25/10000 (0.25% of final total supply of tokens) to the wallet [B] and FTST*215/10000 (2.15% of final total supply of tokens) to the wallet [C]. if (order == 4) { // Saturday, 4 July 2020 г., 23:59:00 require(now >= endICODate + 63072000); token.transfer(walletB, paymentSizeB); token.transfer(walletC, paymentSizeC); completedBC[order] = true; } } } contract Controller is Ownable { Token public token; preICO public pre; ICO public ico; postICO public post; enum State {NONE, PRE_ICO, ICO, POST} State public state; function Controller(address _token, address _preICO, address _ico, address _postICO) public { require(_token != address(0x0)); token = Token(_token); pre = preICO(_preICO); ico = ICO(_ico); post = postICO(_postICO); require(post.endICODate() == ico.endDate()); require(pre.weiRaised() == 0); require(ico.weiRaised() == 0); require(token.totalSupply() == 0); state = State.NONE; } function startPreICO() onlyOwner public { require(state == State.NONE); require(token.owner() == address(this)); token.setSaleAgent(pre); state = State.PRE_ICO; } function startICO() onlyOwner public { require(now > pre.endDate()); require(state == State.PRE_ICO); require(token.owner() == address(this)); token.setSaleAgent(ico); state = State.ICO; } function startPostICO() onlyOwner public { require(now > ico.endDate()); require(state == State.ICO); require(token.owner() == address(this)); token.setSaleAgent(post); state = State.POST; } }
0x6060604052600436106100fb5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305d2035b811461010057806306fdde0314610127578063095ea7b3146101b157806314133a7c146101d357806318160ddd146101f457806323b872dd14610219578063313ce5671461024157806340c10f191461026a578063661884631461028c57806370a08231146102ae5780637d64bcb4146102cd5780638da5cb5b146102e057806395d89b411461030f578063a9059cbb14610322578063b1d6a2f014610344578063d73dd62314610357578063dd62ed3e14610379578063f2fde38b1461039e575b600080fd5b341561010b57600080fd5b6101136103bd565b604051901515815260200160405180910390f35b341561013257600080fd5b61013a6103c6565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561017657808201518382015260200161015e565b50505050905090810190601f1680156101a35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101bc57600080fd5b610113600160a060020a03600435166024356103fd565b34156101de57600080fd5b6101f2600160a060020a03600435166104b1565b005b34156101ff57600080fd5b610207610516565b60405190815260200160405180910390f35b341561022457600080fd5b610113600160a060020a036004358116906024351660443561051c565b341561024c57600080fd5b6102546106ac565b60405160ff909116815260200160405180910390f35b341561027557600080fd5b610113600160a060020a03600435166024356106b1565b341561029757600080fd5b610113600160a060020a03600435166024356107bd565b34156102b957600080fd5b610207600160a060020a03600435166108c8565b34156102d857600080fd5b6101136108e3565b34156102eb57600080fd5b6102f3610955565b604051600160a060020a03909116815260200160405180910390f35b341561031a57600080fd5b61013a610964565b341561032d57600080fd5b610113600160a060020a036004351660243561099b565b341561034f57600080fd5b6102f3610aa4565b341561036257600080fd5b610113600160a060020a0360043516602435610ab8565b341561038457600080fd5b610207600160a060020a0360043581169060243516610b6a565b34156103a957600080fd5b6101f2600160a060020a0360043516610b95565b60045460ff1681565b60408051908101604052600681527f544f4b5049450000000000000000000000000000000000000000000000000000602082015281565b60006002604436101561040c57fe5b82158061043c5750600160a060020a03338116600090815260036020908152604080832093881683529290522054155b151561044757600080fd5b600160a060020a03338116600081815260036020908152604080832094891680845294909152908190208690557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a35060019392505050565b60005433600160a060020a039081169116146104cc57600080fd5b600160a060020a03811615156104e157600080fd5b60048054600160a060020a039092166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179055565b60015481565b60006003606436101561052b57fe5b600160a060020a038416151561054057600080fd5b600160a060020a03851660009081526002602052604090205483111561056557600080fd5b600160a060020a038086166000908152600360209081526040808320339094168352929052205483111561059857600080fd5b600160a060020a0385166000908152600260205260409020546105c1908463ffffffff610c3016565b600160a060020a0380871660009081526002602052604080822093909355908616815220546105f6908463ffffffff610c4216565b600160a060020a0380861660009081526002602090815260408083209490945588831682526003815283822033909316825291909152205461063e908463ffffffff610c3016565b600160a060020a03808716600081815260036020908152604080832033861684529091529081902093909355908616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a3506001949350505050565b601281565b60045460009033600160a060020a0390811661010090920416146106d457600080fd5b60045460ff16156106e457600080fd5b6001546106f7908363ffffffff610c4216565b600155600160a060020a038316600090815260026020526040902054610723908363ffffffff610c4216565b600160a060020a0384166000818152600260205260409081902092909255907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968859084905190815260200160405180910390a2600160a060020a03831660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a350600192915050565b600080600260443610156107cd57fe5b600160a060020a0333811660009081526003602090815260408083209389168352929052205491508184111561082a57600160a060020a033381166000908152600360209081526040808320938916835292905290812055610861565b61083a828563ffffffff610c3016565b600160a060020a033381166000908152600360209081526040808320938a16835292905220555b600160a060020a033381166000818152600360209081526040808320948a168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a3506001949350505050565b600160a060020a031660009081526002602052604090205490565b60045460009033600160a060020a03908116610100909204161461090657600080fd5b60045460ff161561091657600080fd5b6004805460ff191660011790557fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a150600190565b600054600160a060020a031681565b60408051908101604052600381527f544b500000000000000000000000000000000000000000000000000000000000602082015281565b6000600260443610156109aa57fe5b600160a060020a03841615156109bf57600080fd5b600160a060020a0333166000908152600260205260409020548311156109e457600080fd5b600160a060020a033316600090815260026020526040902054610a0d908463ffffffff610c3016565b600160a060020a033381166000908152600260205260408082209390935590861681522054610a42908463ffffffff610c4216565b600160a060020a0380861660008181526002602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a35060019392505050565b6004546101009004600160a060020a031681565b600060026044361015610ac757fe5b600160a060020a03338116600090815260036020908152604080832093881683529290522054610afd908463ffffffff610c4216565b600160a060020a033381166000818152600360209081526040808320948a168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a35060019392505050565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b60005433600160a060020a03908116911614610bb057600080fd5b600160a060020a0381161515610bc557600080fd5b600054600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610c3c57fe5b50900390565b600082820183811015610c5157fe5b93925050505600a165627a7a723058202d403ce0cfc924856473c214ac801ff8f8fa607e03a67d317e5aee49c95e835e0029
[ 5, 16, 4, 7 ]
0xf3bcf23daa33b97a439aebad54e2e1d47a7698a5
// 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 RexInu 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("Rex Inu", "Rex") { 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); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80635342acb4116100de578063a64e4f8a11610097578063af9549e011610071578063af9549e014610462578063b5ed298a1461047e578063d153b60c1461049a578063dd62ed3e146104b857610173565b8063a64e4f8a146103f8578063a901dd9214610416578063a9059cbb1461043257610173565b80635342acb41461030e57806370a082311461033e5780638da5cb5b1461036e5780638fe6cae31461038c57806395d89b41146103aa578063a457c2d7146103c857610173565b8063313ce56711610130578063313ce5671461024c57806334e731221461026a57806338af3eed1461029a57806339509351146102b857806342966c68146102e85780634e71e0c81461030457610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101c65780631ac2874b146101e45780631c31f7101461020057806323b872dd1461021c575b600080fd5b6101806104e8565b60405161018d9190611cf3565b60405180910390f35b6101b060048036038101906101ab91906119ab565b61057a565b6040516101bd9190611cd8565b60405180910390f35b6101ce610598565b6040516101db9190611e75565b60405180910390f35b6101fe60048036038101906101f99190611a10565b6105a2565b005b61021a60048036038101906102159190611892565b610641565b005b61023660048036038101906102319190611920565b610745565b6040516102439190611cd8565b60405180910390f35b610254610846565b6040516102619190611eb9565b60405180910390f35b610284600480360381019061027f9190611a39565b61084f565b6040516102919190611e75565b60405180910390f35b6102a2610872565b6040516102af9190611c6b565b60405180910390f35b6102d260048036038101906102cd91906119ab565b610898565b6040516102df9190611cd8565b60405180910390f35b61030260048036038101906102fd9190611a10565b610944565b005b61030c6109a4565b005b61032860048036038101906103239190611892565b610b01565b6040516103359190611cd8565b60405180910390f35b61035860048036038101906103539190611892565b610b21565b6040516103659190611e75565b60405180910390f35b610376610b69565b6040516103839190611c6b565b60405180910390f35b610394610b8f565b6040516103a19190611e75565b60405180910390f35b6103b2610b95565b6040516103bf9190611cf3565b60405180910390f35b6103e260048036038101906103dd91906119ab565b610c27565b6040516103ef9190611cd8565b60405180910390f35b610400610d1b565b60405161040d9190611cd8565b60405180910390f35b610430600480360381019061042b91906119e7565b610d2e565b005b61044c600480360381019061044791906119ab565b610ddc565b6040516104599190611cd8565b60405180910390f35b61047c6004803603810190610477919061196f565b610dfa565b005b610498600480360381019061049391906118bb565b610ee8565b005b6104a2610f86565b6040516104af9190611c6b565b60405180910390f35b6104d260048036038101906104cd91906118e4565b610fac565b6040516104df9190611e75565b60405180910390f35b6060600380546104f79061209f565b80601f01602080910402602001604051908101604052809291908181526020018280546105239061209f565b80156105705780601f1061054557610100808354040283529160200191610570565b820191906000526020600020905b81548152906001019060200180831161055357829003601f168201915b5050505050905090565b600061058e610587611033565b848461103b565b6001905092915050565b6000600254905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fc57600080fd5b7f8e485513f38ca4c23b0c8170161c4fd5c16f934ea7c068b376f646b0194d1b8e6007548260405161062f929190611e90565b60405180910390a18060078190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461069b57600080fd5b6106a6816001610dfa565b7fe72eaf6addaa195f3c83095031dd08f3a96808dcf047babed1fe4e4f69d6c622600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516106f9929190611c86565b60405180910390a180600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610752848484611206565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061079d611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611db5565b60405180910390fd5b61083a85610829611033565b85846108359190611fd1565b61103b565b60019150509392505050565b60006012905090565b600061271082846108609190611f77565b61086a9190611f46565b905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061093a6108a5611033565b8484600160006108b3611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109359190611ef0565b61103b565b6001905092915050565b61095561094f611033565b826113e6565b600754610960610598565b10156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890611e35565b60405180910390fd5b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109fe57600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b606060048054610ba49061209f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd09061209f565b8015610c1d5780601f10610bf257610100808354040283529160200191610c1d565b820191906000526020600020905b815481529060010190602001808311610c0057829003601f168201915b5050505050905090565b60008060016000610c36611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610cf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cea90611e55565b60405180910390fd5b610d10610cfe611033565b858584610d0b9190611fd1565b61103b565b600191505092915050565b600860149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8857600080fd5b7fba500994dffbabeeb9e430f03a978d7b975359a20c5bde3a6ccb5a0c454680c881604051610db79190611cd8565b60405180910390a180600860146101000a81548160ff02191690831515021790555050565b6000610df0610de9611033565b8484611206565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5457600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f318c131114339c004fff0a22fcdbbc0566bb2a7cd3aa1660e636ec5a66784ff28282604051610edc929190611caf565b60405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4257600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a290611e15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290611d55565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111f99190611e75565b60405180910390a3505050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c90611d95565b60405180910390fd5b600860149054906101000a900460ff1615806112da5750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061132e5750600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113435761133e8383836115ba565b6113e1565b600061135082601961084f565b90506007548161135e610598565b6113689190611fd1565b1061137c5761137784826113e6565b611381565b600090505b600061138e8360c861084f565b90506113bd85600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836115ba565b6113de85858484876113cf9190611fd1565b6113d99190611fd1565b6115ba565b50505b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144d90611dd5565b60405180910390fd5b61146282600083611839565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156114e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114df90611d35565b60405180910390fd5b81816114f49190611fd1565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546115489190611fd1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516115ad9190611e75565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162190611df5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190611d15565b60405180910390fd5b6116a5838383611839565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172290611d75565b60405180910390fd5b81816117379190611fd1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c79190611ef0565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182b9190611e75565b60405180910390a350505050565b505050565b60008135905061184d816124ae565b92915050565b600081359050611862816124c5565b92915050565b600081359050611877816124dc565b92915050565b60008135905061188c816124f3565b92915050565b6000602082840312156118a457600080fd5b60006118b28482850161183e565b91505092915050565b6000602082840312156118cd57600080fd5b60006118db84828501611853565b91505092915050565b600080604083850312156118f757600080fd5b60006119058582860161183e565b92505060206119168582860161183e565b9150509250929050565b60008060006060848603121561193557600080fd5b60006119438682870161183e565b93505060206119548682870161183e565b92505060406119658682870161187d565b9150509250925092565b6000806040838503121561198257600080fd5b60006119908582860161183e565b92505060206119a185828601611868565b9150509250929050565b600080604083850312156119be57600080fd5b60006119cc8582860161183e565b92505060206119dd8582860161187d565b9150509250929050565b6000602082840312156119f957600080fd5b6000611a0784828501611868565b91505092915050565b600060208284031215611a2257600080fd5b6000611a308482850161187d565b91505092915050565b60008060408385031215611a4c57600080fd5b6000611a5a8582860161187d565b9250506020611a6b8582860161187d565b9150509250929050565b611a7e81612005565b82525050565b611a8d81612029565b82525050565b6000611a9e82611ed4565b611aa88185611edf565b9350611ab881856020860161206c565b611ac18161215e565b840191505092915050565b6000611ad9602383611edf565b9150611ae48261216f565b604082019050919050565b6000611afc602283611edf565b9150611b07826121be565b604082019050919050565b6000611b1f602283611edf565b9150611b2a8261220d565b604082019050919050565b6000611b42602683611edf565b9150611b4d8261225c565b604082019050919050565b6000611b65602483611edf565b9150611b70826122ab565b604082019050919050565b6000611b88602883611edf565b9150611b93826122fa565b604082019050919050565b6000611bab602183611edf565b9150611bb682612349565b604082019050919050565b6000611bce602583611edf565b9150611bd982612398565b604082019050919050565b6000611bf1602483611edf565b9150611bfc826123e7565b604082019050919050565b6000611c14601f83611edf565b9150611c1f82612436565b602082019050919050565b6000611c37602583611edf565b9150611c428261245f565b604082019050919050565b611c5681612055565b82525050565b611c658161205f565b82525050565b6000602082019050611c806000830184611a75565b92915050565b6000604082019050611c9b6000830185611a75565b611ca86020830184611a75565b9392505050565b6000604082019050611cc46000830185611a75565b611cd16020830184611a84565b9392505050565b6000602082019050611ced6000830184611a84565b92915050565b60006020820190508181036000830152611d0d8184611a93565b905092915050565b60006020820190508181036000830152611d2e81611acc565b9050919050565b60006020820190508181036000830152611d4e81611aef565b9050919050565b60006020820190508181036000830152611d6e81611b12565b9050919050565b60006020820190508181036000830152611d8e81611b35565b9050919050565b60006020820190508181036000830152611dae81611b58565b9050919050565b60006020820190508181036000830152611dce81611b7b565b9050919050565b60006020820190508181036000830152611dee81611b9e565b9050919050565b60006020820190508181036000830152611e0e81611bc1565b9050919050565b60006020820190508181036000830152611e2e81611be4565b9050919050565b60006020820190508181036000830152611e4e81611c07565b9050919050565b60006020820190508181036000830152611e6e81611c2a565b9050919050565b6000602082019050611e8a6000830184611c4d565b92915050565b6000604082019050611ea56000830185611c4d565b611eb26020830184611c4d565b9392505050565b6000602082019050611ece6000830184611c5c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611efb82612055565b9150611f0683612055565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611f3b57611f3a6120d1565b5b828201905092915050565b6000611f5182612055565b9150611f5c83612055565b925082611f6c57611f6b612100565b5b828204905092915050565b6000611f8282612055565b9150611f8d83612055565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611fc657611fc56120d1565b5b828202905092915050565b6000611fdc82612055565b9150611fe783612055565b925082821015611ffa57611ff96120d1565b5b828203905092915050565b600061201082612035565b9050919050565b600061202282612035565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561208a57808201518184015260208101905061206f565b83811115612099576000848401525b50505050565b600060028204905060018216806120b757607f821691505b602082108114156120cb576120ca61212f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f742073656e6420746f6b656e7320746f20746f6b656e20636f6e7460008201527f7261637400000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f746f74616c20737570706c792065786365656473206d696e20737570706c7900600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6124b781612005565b81146124c257600080fd5b50565b6124ce81612017565b81146124d957600080fd5b50565b6124e581612029565b81146124f057600080fd5b50565b6124fc81612055565b811461250757600080fd5b5056fea2646970667358221220a84e6762df50d304e90c2ef080c193781350ba86c2aa5c62fd6bb133f462beae64736f6c63430008040033
[ 38 ]
0xf3Be7D01462Da82475245097262EE6407Dc789F8
// SPDX-License-Identifier: MIT // Unagi Contracts v1.0.0 (VestingWalletMultiLinear.sol) pragma solidity 0.8.12; import "@openzeppelin/contracts/finance/VestingWallet.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; import "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol"; import "@openzeppelin/contracts/utils/introspection/IERC1820Registry.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import "./Lockable.sol"; /** * @title VestingWalletMultiLinear * @dev This contract handles the vesting of Eth and ERC20 tokens for a given beneficiary. Custody of multiple tokens * can be given to this contract, which will release the token to the beneficiary following a given vesting schedule. * The vesting schedule is customizable through the schedule functions: {addToSchedule} and {resetSchedule}. * * Any token transferred to this contract will follow the vesting schedule as if they were locked from the beginning. * Consequently, if the vesting has already started, any amount of tokens sent to this contract will (at least partly) * be immediately releasable. * * Each schedule step defines how many token will be released for a given duration. * For a step, the release is a linear vesting curve. * * The contract can be paused by PAUSER_ROLE. When contract is paused, token can't be released. * The beneficiary is editable by BENEFICIARY_MANAGER_ROLE. * The schedule is editable by SCHEDULE_MANAGER_ROLE when the contract is not locked. * * @custom:security-contact [email protected] */ contract VestingWalletMultiLinear is VestingWallet, IERC777Recipient, Pausable, AccessControlEnumerable, Lockable { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant SCHEDULE_MANAGER_ROLE = keccak256("SCHEDULE_MANAGER_ROLE"); bytes32 public constant BENEFICIARY_MANAGER_ROLE = keccak256("BENEFICIARY_MANAGER_ROLE"); IERC1820Registry internal constant _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); bytes32 private constant _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient"); struct ScheduleStep { uint8 percent; uint256 start; uint64 duration; } ScheduleStep[] private _sortedSchedule; uint8 private _stepPercentSum; address private _beneficiary; uint64 private _duration; /** * @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet. * Register ERC1820 interface implementer * Setup roles */ constructor(address beneficiaryAddress, uint64 startTimestamp) VestingWallet(beneficiaryAddress, startTimestamp, 0) { _ERC1820_REGISTRY.setInterfaceImplementer( address(this), _TOKENS_RECIPIENT_INTERFACE_HASH, address(this) ); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(PAUSER_ROLE, msg.sender); _grantRole(SCHEDULE_MANAGER_ROLE, msg.sender); _grantRole(BENEFICIARY_MANAGER_ROLE, msg.sender); setBeneficiary(beneficiaryAddress); } /** * @dev See {IERC777Recipient-tokensReceived}. */ function tokensReceived( address, address, address, uint256, bytes calldata, bytes calldata ) external override {} /** * @dev Pause token releases. */ function pause() external onlyRole(PAUSER_ROLE) { _pause(); } /** * @dev Unpause token releases. * * Requirements: * * - Caller must have role PAUSER_ROLE. */ function unpause() external onlyRole(PAUSER_ROLE) { _unpause(); } /** * @dev Lock schedule edition for a duration. * * Requirements: * * - Caller must have role DEFAULT_ADMIN_ROLE. */ function lock(uint256 lockDuration) external onlyRole(DEFAULT_ADMIN_ROLE) { _lock(lockDuration); } /** * @dev Permanently lock schedule edition. * * Requirements: * * - Caller must have role DEFAULT_ADMIN_ROLE. */ function permanentLock() external onlyRole(DEFAULT_ADMIN_ROLE) { _permanentLock(); } /** * @dev Getter for the beneficiary address. */ function beneficiary() public view override returns (address) { return _beneficiary; } /** * @dev Setter for the beneficiary address. * Emits a {BeneficiaryEdited} event. * * Requirements: * * - Caller must have role BENEFICIARY_MANAGER_ROLE. */ function setBeneficiary(address beneficiaryAddress) public onlyRole(BENEFICIARY_MANAGER_ROLE) { require( beneficiaryAddress != address(0), "VestingWalletMultiLinear: beneficiary is zero address" ); _beneficiary = beneficiaryAddress; emit BeneficiaryEdited(beneficiaryAddress); } /** * @dev Add a step to the schedule. * Emits a {ScheduleStepAdded} event. * * Requirements: * * - Caller must have role SCHEDULE_MANAGER_ROLE. * - step percent sum should not go above 100. */ function addToSchedule(uint8 stepPercent, uint64 stepDuration) external onlyRole(SCHEDULE_MANAGER_ROLE) whenNotLocked { require( _stepPercentSum + stepPercent <= 100, "VestingWalletMultiLinear: stepPercentSum above 100. Double check schedule and/or rebuild it." ); _sortedSchedule.push( ScheduleStep(stepPercent, start() + duration(), stepDuration) ); _stepPercentSum += stepPercent; _duration += stepDuration; emit ScheduleStepAdded(stepPercent, stepDuration); } /** * @dev Delete all steps of the schedule. * Emits a {ScheduleReset} event. * * Requirements: * * - Caller must have role SCHEDULE_MANAGER_ROLE. * - The contract must not be locked. */ function resetSchedule() external onlyRole(SCHEDULE_MANAGER_ROLE) whenNotLocked { delete _sortedSchedule; _stepPercentSum = 0; _duration = 0; emit ScheduleReset(); } /** * @dev Getter for the step percent sum. */ function stepPercentSum() external view returns (uint8) { return _stepPercentSum; } /** * @dev Getter for the vesting duration. */ function duration() public view override returns (uint256) { return _duration; } /** * @dev Release the native token (ether) that have already vested. * * Emits a {TokensReleased} event. * * Requirements: * * - The contract must not be paused. */ function release() public override whenNotPaused { super.release(); } /** * @dev Release the tokens that have already vested. * * Emits a {TokensReleased} event. * * Requirements: * * - The contract must not be paused. */ function release(address token) public override whenNotPaused { super.release(token); } /** * @dev Implementation of the vesting formula. This returns the amount vested, * as a function of time, for an asset given its total historical allocation. */ function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view override returns (uint256) { require( _sortedSchedule.length > 0, "VestingWalletMultiLinear: Schedule is empty. Call addToSchedule(uint8 stepPercent, uint64 stepDuration) first." ); uint256 amountVested = 0; uint256 index = 0; ScheduleStep storage currentStep; do { currentStep = _sortedSchedule[index]; amountVested += _vestingScheduleAtStep( currentStep, totalAllocation, timestamp ); index += 1; } while ( timestamp > currentStep.start && index < _sortedSchedule.length ); return amountVested; } /** * @dev Implementation of the vesting formula for a given step. This returns the amount vested, * as a linear function of time, for an asset given its total historical allocation. */ function _vestingScheduleAtStep( ScheduleStep storage step, uint256 totalAllocation, uint64 timestamp ) private view returns (uint256) { uint256 stepAllocation = (totalAllocation * step.percent) / 100; if (timestamp < step.start) { return 0; } else if (timestamp >= step.start + step.duration) { return stepAllocation; } else { return (stepAllocation * (timestamp - step.start)) / step.duration; } } event BeneficiaryEdited(address beneficiaryAddress); event ScheduleReset(); event ScheduleStepAdded(uint8 stepPercent, uint64 stepDuration); } // SPDX-License-Identifier: MIT // Unagi Contracts v1.0.0 (Lockable.sol) pragma solidity 0.8.12; import "@openzeppelin/contracts/utils/Context.sol"; /** * @dev Contract module which allows children to implement a lock * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotLocked` and `whenLocked`, which can be applied to * the functions of your contract. Note that they will not be lockable by * simply including this module, only once the modifiers are put in place. */ abstract contract Lockable is Context { /** * @dev Emitted when the lock is triggered by `account` for `duration`. */ event Locked(address account, uint256 duration); /** * @dev Emitted when the lock is triggered by `account` permanently. */ event PermanentlyLocked(address account); bool private _permanentlyLocked; uint256 private _lockEnd; /** * @dev Initializes the contract in unlocked state. */ constructor() { _permanentlyLocked = false; _lockEnd = 0; } /** * @dev Getter for the permanently locked. */ function permanentlyLocked() public view virtual returns (bool) { return _permanentlyLocked; } /** * @dev Returns true if the contract is locked, and false otherwise. */ function locked() public view virtual returns (bool) { return permanentlyLocked() || _lockEnd > block.timestamp; } /** * @dev Modifier to make a function callable only when the contract is not locked. * * Requirements: * * - The contract must not be locked. */ modifier whenNotLocked() { require(!locked(), "Lockable: locked"); _; } /** * @dev Modifier to make a function callable only when the contract is locked. * * Requirements: * * - The contract must be locked. */ modifier whenLocked() { require(locked(), "Lockable: not locked"); _; } /** * @dev Getter for the lock end. * * Requirements: * * - The contract must be temporary locked. */ function lockEnd() external view virtual whenLocked returns (uint256) { require(!permanentlyLocked(), "Lockable: not temporary locked"); return _lockEnd; } /** * @dev Triggers locked state for a defined duration. * * Requirements: * * - The contract must not be locked. */ function _lock(uint256 duration) internal virtual whenNotLocked { _lockEnd = block.timestamp + duration; emit Locked(_msgSender(), duration); } /** * @dev Triggers locked state permanently. * * Requirements: * * - The contract must not be locked. */ function _permanentLock() internal virtual whenNotLocked { _permanentlyLocked = true; emit PermanentlyLocked(_msgSender()); } } // 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/structs/EnumerableMap.sol) pragma solidity ^0.8.0; import "./EnumerableSet.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set( Map storage map, bytes32 key, bytes32 value ) private returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (_contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get( Map storage map, bytes32 key, string memory errorMessage ) private view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || _contains(map, key), errorMessage); return value; } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToAddressMap storage map, uint256 key, address value ) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToAddressMap storage map, uint256 key, string memory errorMessage ) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (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/IERC1820Registry.sol) pragma solidity ^0.8.0; /** * @dev Interface of the global ERC1820 Registry, as defined in the * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register * implementers for interfaces in this registry, as well as query support. * * Implementers may be shared by multiple accounts, and can also implement more * than a single interface for each account. Contracts can implement interfaces * for themselves, but externally-owned accounts (EOA) must delegate this to a * contract. * * {IERC165} interfaces can also be queried via the registry. * * For an in-depth explanation and source code analysis, see the EIP text. */ interface IERC1820Registry { /** * @dev Sets `newManager` as the manager for `account`. A manager of an * account is able to set interface implementers for it. * * By default, each account is its own manager. Passing a value of `0x0` in * `newManager` will reset the manager to this initial state. * * Emits a {ManagerChanged} event. * * Requirements: * * - the caller must be the current manager for `account`. */ function setManager(address account, address newManager) external; /** * @dev Returns the manager for `account`. * * See {setManager}. */ function getManager(address account) external view returns (address); /** * @dev Sets the `implementer` contract as ``account``'s implementer for * `interfaceHash`. * * `account` being the zero address is an alias for the caller's address. * The zero address can also be used in `implementer` to remove an old one. * * See {interfaceHash} to learn how these are created. * * Emits an {InterfaceImplementerSet} event. * * Requirements: * * - the caller must be the current manager for `account`. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not * end in 28 zeroes). * - `implementer` must implement {IERC1820Implementer} and return true when * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ function setInterfaceImplementer( address account, bytes32 _interfaceHash, address implementer ) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such * implementer is registered, returns the zero address. * * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 * zeroes), `account` will be queried for support of it. * * `account` being the zero address is an alias for the caller's address. */ function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address); /** * @dev Returns the interface hash for an `interfaceName`, as defined in the * corresponding * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. */ function interfaceHash(string calldata interfaceName) external pure returns (bytes32); /** * @notice Updates the cache with whether the contract implements an ERC165 interface or not. * @param account Address of the contract for which to update the cache. * @param interfaceId ERC165 interface for which to update the cache. */ function updateERC165Cache(address account, bytes4 interfaceId) external; /** * @notice Checks whether a contract implements an ERC165 interface or not. * If the result is not cached a direct lookup on the contract address is performed. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling * {updateERC165Cache} with the contract address. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); /** * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); event ManagerChanged(address indexed account, address indexed newManager); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Recipient.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. * * Accounts can be notified of {IERC777} tokens being sent to them by having a * contract implement this interface (contract holders can be their own * implementer) and registering it on the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. * * See {IERC1820Registry} and {ERC1820Implementer}. */ interface IERC777Recipient { /** * @dev Called by an {IERC777} token contract whenever tokens are being * moved or created into a registered account (`to`). The type of operation * is conveyed by `from` being the zero address or not. * * This call occurs _after_ the token contract's state is updated, so * {IERC777-balanceOf}, etc., can be used to query the post-operation state. * * This function may revert to prevent the operation from being executed. */ function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @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 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (finance/VestingWallet.sol) pragma solidity ^0.8.0; import "../token/ERC20/utils/SafeERC20.sol"; import "../utils/Address.sol"; import "../utils/Context.sol"; import "../utils/math/Math.sol"; /** * @title VestingWallet * @dev This contract handles the vesting of Eth and ERC20 tokens for a given beneficiary. Custody of multiple tokens * can be given to this contract, which will release the token to the beneficiary following a given vesting schedule. * The vesting schedule is customizable through the {vestedAmount} function. * * Any token transferred to this contract will follow the vesting schedule as if they were locked from the beginning. * Consequently, if the vesting has already started, any amount of tokens sent to this contract will (at least partly) * be immediately releasable. */ contract VestingWallet is Context { event EtherReleased(uint256 amount); event ERC20Released(address indexed token, uint256 amount); uint256 private _released; mapping(address => uint256) private _erc20Released; address private immutable _beneficiary; uint64 private immutable _start; uint64 private immutable _duration; /** * @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet. */ constructor( address beneficiaryAddress, uint64 startTimestamp, uint64 durationSeconds ) { require(beneficiaryAddress != address(0), "VestingWallet: beneficiary is zero address"); _beneficiary = beneficiaryAddress; _start = startTimestamp; _duration = durationSeconds; } /** * @dev The contract should be able to receive Eth. */ receive() external payable virtual {} /** * @dev Getter for the beneficiary address. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @dev Getter for the start timestamp. */ function start() public view virtual returns (uint256) { return _start; } /** * @dev Getter for the vesting duration. */ function duration() public view virtual returns (uint256) { return _duration; } /** * @dev Amount of eth already released */ function released() public view virtual returns (uint256) { return _released; } /** * @dev Amount of token already released */ function released(address token) public view virtual returns (uint256) { return _erc20Released[token]; } /** * @dev Release the native token (ether) that have already vested. * * Emits a {TokensReleased} event. */ function release() public virtual { uint256 releasable = vestedAmount(uint64(block.timestamp)) - released(); _released += releasable; emit EtherReleased(releasable); Address.sendValue(payable(beneficiary()), releasable); } /** * @dev Release the tokens that have already vested. * * Emits a {TokensReleased} event. */ function release(address token) public virtual { uint256 releasable = vestedAmount(token, uint64(block.timestamp)) - released(token); _erc20Released[token] += releasable; emit ERC20Released(token, releasable); SafeERC20.safeTransfer(IERC20(token), beneficiary(), releasable); } /** * @dev Calculates the amount of ether that has already vested. Default implementation is a linear vesting curve. */ function vestedAmount(uint64 timestamp) public view virtual returns (uint256) { return _vestingSchedule(address(this).balance + released(), timestamp); } /** * @dev Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve. */ function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) { return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp); } /** * @dev Virtual implementation of the vesting formula. This returns the amout vested, as a function of time, for * an asset given its total historical allocation. */ function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual returns (uint256) { if (timestamp < start()) { return 0; } else if (timestamp > start() + duration()) { return totalAllocation; } else { return (totalAllocation * (timestamp - start())) / duration(); } } } // 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 (last updated v4.5.0) (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 virtual 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 virtual 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 (last updated v4.5.0) (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 virtual 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 virtual { 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 virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ 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()); } } }
0x6080604052600436106101fc5760003560e01c806386d1a69f1161010d578063a66d1f05116100a0578063cf3090121161006f578063cf30901214610709578063d547741f14610734578063dd4670641461075d578063e63ab1e914610786578063ee5bafbe146107b157610203565b8063a66d1f0514610673578063bd2404be1461068a578063be9a6555146106a1578063ca15c873146106cc57610203565b806396132521116100dc57806396132521146105b55780639852595c146105e0578063a0ee45011461061d578063a217fddf1461064857610203565b806386d1a69f146104f95780639010d07c146105105780639051c5971461054d57806391d148541461057857610203565b806336568abe116101905780633f4ba83a1161015f5780633f4ba83a146104385780635c975abb1461044f5780635de43aec1461047a578063810ec23b146104a55780638456cb59146104e257610203565b806336568abe1461038e57806336f9820d146103b7578063371d4b7c146103e257806338af3eed1461040d57610203565b806319165587116101cc57806319165587146102d65780631c31f710146102ff578063248a9ca3146103285780632f2ff15d1461036557610203565b806223de291461020857806301ffc9a7146102315780630a17b06b1461026e5780630fb5a6b4146102ab57610203565b3661020357005b600080fd5b34801561021457600080fd5b5061022f600480360381019061022a919061266b565b6107da565b005b34801561023d57600080fd5b5061025860048036038101906102539190612792565b6107e4565b60405161026591906127da565b60405180910390f35b34801561027a57600080fd5b5061029560048036038101906102909190612835565b61085e565b6040516102a29190612871565b60405180910390f35b3480156102b757600080fd5b506102c0610883565b6040516102cd9190612871565b60405180910390f35b3480156102e257600080fd5b506102fd60048036038101906102f8919061288c565b6108ab565b005b34801561030b57600080fd5b506103266004803603810190610321919061288c565b6108ff565b005b34801561033457600080fd5b5061034f600480360381019061034a91906128ef565b610a1d565b60405161035c919061292b565b60405180910390f35b34801561037157600080fd5b5061038c60048036038101906103879190612946565b610a3d565b005b34801561039a57600080fd5b506103b560048036038101906103b09190612946565b610a66565b005b3480156103c357600080fd5b506103cc610ae9565b6040516103d9919061292b565b60405180910390f35b3480156103ee57600080fd5b506103f7610b0d565b60405161040491906129a2565b60405180910390f35b34801561041957600080fd5b50610422610b24565b60405161042f91906129cc565b60405180910390f35b34801561044457600080fd5b5061044d610b4e565b005b34801561045b57600080fd5b50610464610b8b565b60405161047191906127da565b60405180910390f35b34801561048657600080fd5b5061048f610ba2565b60405161049c919061292b565b60405180910390f35b3480156104b157600080fd5b506104cc60048036038101906104c791906129e7565b610bc6565b6040516104d99190612871565b60405180910390f35b3480156104ee57600080fd5b506104f7610c66565b005b34801561050557600080fd5b5061050e610ca3565b005b34801561051c57600080fd5b5061053760048036038101906105329190612a27565b610cf5565b60405161054491906129cc565b60405180910390f35b34801561055957600080fd5b50610562610d24565b60405161056f91906127da565b60405180910390f35b34801561058457600080fd5b5061059f600480360381019061059a9190612946565b610d3b565b6040516105ac91906127da565b60405180910390f35b3480156105c157600080fd5b506105ca610da6565b6040516105d79190612871565b60405180910390f35b3480156105ec57600080fd5b506106076004803603810190610602919061288c565b610daf565b6040516106149190612871565b60405180910390f35b34801561062957600080fd5b50610632610df8565b60405161063f9190612871565b60405180910390f35b34801561065457600080fd5b5061065d610e91565b60405161066a919061292b565b60405180910390f35b34801561067f57600080fd5b50610688610e98565b005b34801561069657600080fd5b5061069f610eb8565b005b3480156106ad57600080fd5b506106b6610fb5565b6040516106c39190612871565b60405180910390f35b3480156106d857600080fd5b506106f360048036038101906106ee91906128ef565b610fe7565b6040516107009190612871565b60405180910390f35b34801561071557600080fd5b5061071e61100b565b60405161072b91906127da565b60405180910390f35b34801561074057600080fd5b5061075b60048036038101906107569190612946565b611026565b005b34801561076957600080fd5b50610784600480360381019061077f9190612a67565b61104f565b005b34801561079257600080fd5b5061079b611071565b6040516107a8919061292b565b60405180910390f35b3480156107bd57600080fd5b506107d860048036038101906107d39190612ac0565b611095565b005b5050505050505050565b60007f5a05180f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610857575061085682611644565b5b9050919050565b600061087c61086b610da6565b476108769190612b2f565b836116be565b9050919050565b6000600860159054906101000a900467ffffffffffffffff1667ffffffffffffffff16905090565b6108b3610b8b565b156108f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ea90612be2565b60405180910390fd5b6108fc81611789565b50565b7fc59ec23d1c349d9976a1aba1c27c681cc250eafcb2aaf5c7c3be1d0e6827bfb16109318161092c611864565b61186c565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890612c74565b60405180910390fd5b81600860016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f446c2ff852422a9988931e1b4eed7290482a93fa1eff1e2fc9295efde537ffb082604051610a1191906129cc565b60405180910390a15050565b600060036000838152602001908152602001600020600101549050919050565b610a4682610a1d565b610a5781610a52611864565b61186c565b610a618383611909565b505050565b610a6e611864565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610adb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad290612d06565b60405180910390fd5b610ae5828261193d565b5050565b7f54217f7b85353d04ece159ebd69a45e9b8287dd2043746eaca469996a3d91aee81565b6000600860009054906101000a900460ff16905090565b6000600860019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a610b8081610b7b611864565b61186c565b610b88611971565b50565b6000600260009054906101000a900460ff16905090565b7fc59ec23d1c349d9976a1aba1c27c681cc250eafcb2aaf5c7c3be1d0e6827bfb181565b6000610c5e610bd484610daf565b8473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610c0d91906129cc565b602060405180830381865afa158015610c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c4e9190612d3b565b610c589190612b2f565b836116be565b905092915050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a610c9881610c93611864565b61186c565b610ca0611a13565b50565b610cab610b8b565b15610ceb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce290612be2565b60405180910390fd5b610cf3611ab6565b565b6000610d1c8260046000868152602001908152602001600020611b3890919063ffffffff16565b905092915050565b6000600560009054906101000a900460ff16905090565b60006003600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60008054905090565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000610e0261100b565b610e41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3890612db4565b60405180910390fd5b610e49610d24565b15610e89576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8090612e20565b60405180910390fd5b600654905090565b6000801b81565b6000801b610ead81610ea8611864565b61186c565b610eb5611b52565b50565b7f54217f7b85353d04ece159ebd69a45e9b8287dd2043746eaca469996a3d91aee610eea81610ee5611864565b61186c565b610ef261100b565b15610f32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2990612e8c565b60405180910390fd5b60076000610f4091906124f6565b6000600860006101000a81548160ff021916908360ff1602179055506000600860156101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055507f145deea571fed01c02d67148dbd971d8f6daf03869c1b8094831bf4e3b2bf40e60405160405180910390a150565b60007f00000000000000000000000000000000000000000000000000000000625e62ea67ffffffffffffffff16905090565b600061100460046000848152602001908152602001600020611bf5565b9050919050565b6000611015610d24565b80611021575042600654115b905090565b61102f82610a1d565b6110408161103b611864565b61186c565b61104a838361193d565b505050565b6000801b6110648161105f611864565b61186c565b61106d82611c0a565b5050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b7f54217f7b85353d04ece159ebd69a45e9b8287dd2043746eaca469996a3d91aee6110c7816110c2611864565b61186c565b6110cf61100b565b1561110f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161110690612e8c565b60405180910390fd5b606483600860009054906101000a900460ff1661112c9190612eac565b60ff161115611170576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116790612f7b565b60405180910390fd5b600760405180606001604052808560ff16815260200161118e610883565b611196610fb5565b6111a09190612b2f565b81526020018467ffffffffffffffff16815250908060018154018082558091505060019003906000526020600020906003020160009091909190915060008201518160000160006101000a81548160ff021916908360ff1602179055506020820151816001015560408201518160020160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550505082600860008282829054906101000a900460ff166112569190612eac565b92506101000a81548160ff021916908360ff16021790555081600860158282829054906101000a900467ffffffffffffffff166112939190612f9b565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055507f9126313d5e85a57af5bf04159f331340677115f459ea598e9c41936fff80b42e83836040516112ea929190612fe8565b60405180910390a1505050565b6113018282610d3b565b6113d45760016003600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611379611864565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6000611400836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611ca7565b905092915050565b60606000600283600261141b9190613011565b6114259190612b2f565b67ffffffffffffffff81111561143e5761143d61306b565b5b6040519080825280601f01601f1916602001820160405280156114705781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106114a8576114a761309a565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061150c5761150b61309a565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000600184600261154c9190613011565b6115569190612b2f565b90505b60018111156115f6577f3031323334353637383961626364656600000000000000000000000000000000600f8616601081106115985761159761309a565b5b1a60f81b8282815181106115af576115ae61309a565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c9450806115ef906130c9565b9050611559565b506000841461163a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116319061313f565b60405180910390fd5b8091505092915050565b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806116b757506116b682611d17565b5b9050919050565b60008060078054905011611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe9061321d565b60405180910390fd5b60008060005b600782815481106117215761172061309a565b5b9060005260206000209060030201905061173c818787611d81565b836117479190612b2f565b92506001826117569190612b2f565b915080600101548567ffffffffffffffff16118015611779575060078054905082105b61170d5782935050505092915050565b600061179482610daf565b61179e8342610bc6565b6117a8919061323d565b905080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117f99190612b2f565b925050819055508173ffffffffffffffffffffffffffffffffffffffff167fc0e523490dd523c33b1878c9eb14ff46991e3f5b2cd33710918618f2a39cba1b826040516118469190612871565b60405180910390a26118608261185a610b24565b83611e7a565b5050565b600033905090565b6118768282610d3b565b6119055761189b8173ffffffffffffffffffffffffffffffffffffffff166014611408565b6118a98360001c6020611408565b6040516020016118ba929190613383565b6040516020818303038152906040526040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118fc9190613407565b60405180910390fd5b5050565b61191382826112f7565b61193881600460008581526020019081526020016000206113d890919063ffffffff16565b505050565b6119478282611f00565b61196c8160046000858152602001908152602001600020611fe290919063ffffffff16565b505050565b611979610b8b565b6119b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119af90613475565b60405180910390fd5b6000600260006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6119fc611864565b604051611a0991906129cc565b60405180910390a1565b611a1b610b8b565b15611a5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5290612be2565b60405180910390fd5b6001600260006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611a9f611864565b604051611aac91906129cc565b60405180910390a1565b6000611ac0610da6565b611ac94261085e565b611ad3919061323d565b905080600080828254611ae69190612b2f565b925050819055507fda9d4e5f101b8b9b1c5b76d0c5a9f7923571acfc02376aa076b75a8c080c956b81604051611b1c9190612871565b60405180910390a1611b35611b2f610b24565b82612012565b50565b6000611b478360000183612106565b60001c905092915050565b611b5a61100b565b15611b9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9190612e8c565b60405180910390fd5b6001600560006101000a81548160ff0219169083151502179055507fec6267e1ebfb5a47f9aceaa24ea9a743edce3f5159589b9e11239aeec797f2d5611bde611864565b604051611beb91906129cc565b60405180910390a1565b6000611c0382600001612131565b9050919050565b611c1261100b565b15611c52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4990612e8c565b60405180910390fd5b8042611c5e9190612b2f565b6006819055507f9f1ec8c880f76798e7b793325d625e9b60e4082a553c98f42b6cda368dd60008611c8d611864565b82604051611c9c929190613495565b60405180910390a150565b6000611cb38383612142565b611d0c578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050611d11565b600090505b92915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008060648560000160009054906101000a900460ff1660ff1685611da69190613011565b611db091906134ed565b905084600101548367ffffffffffffffff161015611dd2576000915050611e73565b8460020160009054906101000a900467ffffffffffffffff1667ffffffffffffffff168560010154611e049190612b2f565b8367ffffffffffffffff1610611e1d5780915050611e73565b8460020160009054906101000a900467ffffffffffffffff1667ffffffffffffffff1685600101548467ffffffffffffffff16611e5a919061323d565b82611e659190613011565b611e6f91906134ed565b9150505b9392505050565b611efb8363a9059cbb60e01b8484604051602401611e99929190613495565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612165565b505050565b611f0a8282610d3b565b15611fde5760006003600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611f83611864565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600061200a836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61222c565b905092915050565b80471015612055576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161204c9061356a565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405161207b906135bb565b60006040518083038185875af1925050503d80600081146120b8576040519150601f19603f3d011682016040523d82523d6000602084013e6120bd565b606091505b5050905080612101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120f890613642565b60405180910390fd5b505050565b600082600001828154811061211e5761211d61309a565b5b9060005260206000200154905092915050565b600081600001805490509050919050565b600080836001016000848152602001908152602001600020541415905092915050565b60006121c7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166123409092919063ffffffff16565b905060008151111561222757808060200190518101906121e7919061368e565b612226576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221d9061372d565b60405180910390fd5b5b505050565b6000808360010160008481526020019081526020016000205490506000811461233457600060018261225e919061323d565b9050600060018660000180549050612276919061323d565b90508181146122e55760008660000182815481106122975761229661309a565b5b90600052602060002001549050808760000184815481106122bb576122ba61309a565b5b90600052602060002001819055508387600101600083815260200190815260200160002081905550505b856000018054806122f9576122f861374d565b5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061233a565b60009150505b92915050565b606061234f8484600085612358565b90509392505050565b60608247101561239d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612394906137ee565b60405180910390fd5b6123a68561246c565b6123e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123dc9061385a565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161240e91906138b6565b60006040518083038185875af1925050503d806000811461244b576040519150601f19603f3d011682016040523d82523d6000602084013e612450565b606091505b509150915061246082828661248f565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6060831561249f578290506124ef565b6000835111156124b25782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124e69190613407565b60405180910390fd5b9392505050565b5080546000825560030290600052602060002090810190612517919061251a565b50565b5b8082111561256457600080820160006101000a81549060ff021916905560018201600090556002820160006101000a81549067ffffffffffffffff02191690555060030161251b565b5090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061259d82612572565b9050919050565b6125ad81612592565b81146125b857600080fd5b50565b6000813590506125ca816125a4565b92915050565b6000819050919050565b6125e3816125d0565b81146125ee57600080fd5b50565b600081359050612600816125da565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261262b5761262a612606565b5b8235905067ffffffffffffffff8111156126485761264761260b565b5b60208301915083600182028301111561266457612663612610565b5b9250929050565b60008060008060008060008060c0898b03121561268b5761268a612568565b5b60006126998b828c016125bb565b98505060206126aa8b828c016125bb565b97505060406126bb8b828c016125bb565b96505060606126cc8b828c016125f1565b955050608089013567ffffffffffffffff8111156126ed576126ec61256d565b5b6126f98b828c01612615565b945094505060a089013567ffffffffffffffff81111561271c5761271b61256d565b5b6127288b828c01612615565b92509250509295985092959890939650565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61276f8161273a565b811461277a57600080fd5b50565b60008135905061278c81612766565b92915050565b6000602082840312156127a8576127a7612568565b5b60006127b68482850161277d565b91505092915050565b60008115159050919050565b6127d4816127bf565b82525050565b60006020820190506127ef60008301846127cb565b92915050565b600067ffffffffffffffff82169050919050565b612812816127f5565b811461281d57600080fd5b50565b60008135905061282f81612809565b92915050565b60006020828403121561284b5761284a612568565b5b600061285984828501612820565b91505092915050565b61286b816125d0565b82525050565b60006020820190506128866000830184612862565b92915050565b6000602082840312156128a2576128a1612568565b5b60006128b0848285016125bb565b91505092915050565b6000819050919050565b6128cc816128b9565b81146128d757600080fd5b50565b6000813590506128e9816128c3565b92915050565b60006020828403121561290557612904612568565b5b6000612913848285016128da565b91505092915050565b612925816128b9565b82525050565b6000602082019050612940600083018461291c565b92915050565b6000806040838503121561295d5761295c612568565b5b600061296b858286016128da565b925050602061297c858286016125bb565b9150509250929050565b600060ff82169050919050565b61299c81612986565b82525050565b60006020820190506129b76000830184612993565b92915050565b6129c681612592565b82525050565b60006020820190506129e160008301846129bd565b92915050565b600080604083850312156129fe576129fd612568565b5b6000612a0c858286016125bb565b9250506020612a1d85828601612820565b9150509250929050565b60008060408385031215612a3e57612a3d612568565b5b6000612a4c858286016128da565b9250506020612a5d858286016125f1565b9150509250929050565b600060208284031215612a7d57612a7c612568565b5b6000612a8b848285016125f1565b91505092915050565b612a9d81612986565b8114612aa857600080fd5b50565b600081359050612aba81612a94565b92915050565b60008060408385031215612ad757612ad6612568565b5b6000612ae585828601612aab565b9250506020612af685828601612820565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612b3a826125d0565b9150612b45836125d0565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612b7a57612b79612b00565b5b828201905092915050565b600082825260208201905092915050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b6000612bcc601083612b85565b9150612bd782612b96565b602082019050919050565b60006020820190508181036000830152612bfb81612bbf565b9050919050565b7f56657374696e6757616c6c65744d756c74694c696e6561723a2062656e65666960008201527f6369617279206973207a65726f20616464726573730000000000000000000000602082015250565b6000612c5e603583612b85565b9150612c6982612c02565b604082019050919050565b60006020820190508181036000830152612c8d81612c51565b9050919050565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b6000612cf0602f83612b85565b9150612cfb82612c94565b604082019050919050565b60006020820190508181036000830152612d1f81612ce3565b9050919050565b600081519050612d35816125da565b92915050565b600060208284031215612d5157612d50612568565b5b6000612d5f84828501612d26565b91505092915050565b7f4c6f636b61626c653a206e6f74206c6f636b6564000000000000000000000000600082015250565b6000612d9e601483612b85565b9150612da982612d68565b602082019050919050565b60006020820190508181036000830152612dcd81612d91565b9050919050565b7f4c6f636b61626c653a206e6f742074656d706f72617279206c6f636b65640000600082015250565b6000612e0a601e83612b85565b9150612e1582612dd4565b602082019050919050565b60006020820190508181036000830152612e3981612dfd565b9050919050565b7f4c6f636b61626c653a206c6f636b656400000000000000000000000000000000600082015250565b6000612e76601083612b85565b9150612e8182612e40565b602082019050919050565b60006020820190508181036000830152612ea581612e69565b9050919050565b6000612eb782612986565b9150612ec283612986565b92508260ff03821115612ed857612ed7612b00565b5b828201905092915050565b7f56657374696e6757616c6c65744d756c74694c696e6561723a2073746570506560008201527f7263656e7453756d2061626f7665203130302e20446f75626c6520636865636b60208201527f207363686564756c6520616e642f6f722072656275696c642069742e00000000604082015250565b6000612f65605c83612b85565b9150612f7082612ee3565b606082019050919050565b60006020820190508181036000830152612f9481612f58565b9050919050565b6000612fa6826127f5565b9150612fb1836127f5565b92508267ffffffffffffffff03821115612fce57612fcd612b00565b5b828201905092915050565b612fe2816127f5565b82525050565b6000604082019050612ffd6000830185612993565b61300a6020830184612fd9565b9392505050565b600061301c826125d0565b9150613027836125d0565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156130605761305f612b00565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006130d4826125d0565b915060008214156130e8576130e7612b00565b5b600182039050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b6000613129602083612b85565b9150613134826130f3565b602082019050919050565b600060208201905081810360008301526131588161311c565b9050919050565b7f56657374696e6757616c6c65744d756c74694c696e6561723a2053636865647560008201527f6c6520697320656d7074792e2043616c6c20616464546f5363686564756c652860208201527f75696e7438207374657050657263656e742c2075696e7436342073746570447560408201527f726174696f6e292066697273742e000000000000000000000000000000000000606082015250565b6000613207606e83612b85565b91506132128261315f565b608082019050919050565b60006020820190508181036000830152613236816131fa565b9050919050565b6000613248826125d0565b9150613253836125d0565b92508282101561326657613265612b00565b5b828203905092915050565b600081905092915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b60006132b2601783613271565b91506132bd8261327c565b601782019050919050565b600081519050919050565b60005b838110156132f15780820151818401526020810190506132d6565b83811115613300576000848401525b50505050565b6000613311826132c8565b61331b8185613271565b935061332b8185602086016132d3565b80840191505092915050565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b600061336d601183613271565b915061337882613337565b601182019050919050565b600061338e826132a5565b915061339a8285613306565b91506133a582613360565b91506133b18284613306565b91508190509392505050565b6000601f19601f8301169050919050565b60006133d9826132c8565b6133e38185612b85565b93506133f38185602086016132d3565b6133fc816133bd565b840191505092915050565b6000602082019050818103600083015261342181846133ce565b905092915050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b600061345f601483612b85565b915061346a82613429565b602082019050919050565b6000602082019050818103600083015261348e81613452565b9050919050565b60006040820190506134aa60008301856129bd565b6134b76020830184612862565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006134f8826125d0565b9150613503836125d0565b925082613513576135126134be565b5b828204905092915050565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b6000613554601d83612b85565b915061355f8261351e565b602082019050919050565b6000602082019050818103600083015261358381613547565b9050919050565b600081905092915050565b50565b60006135a560008361358a565b91506135b082613595565b600082019050919050565b60006135c682613598565b9150819050919050565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b600061362c603a83612b85565b9150613637826135d0565b604082019050919050565b6000602082019050818103600083015261365b8161361f565b9050919050565b61366b816127bf565b811461367657600080fd5b50565b60008151905061368881613662565b92915050565b6000602082840312156136a4576136a3612568565b5b60006136b284828501613679565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000613717602a83612b85565b9150613722826136bb565b604082019050919050565b600060208201905081810360008301526137468161370a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006137d8602683612b85565b91506137e38261377c565b604082019050919050565b60006020820190508181036000830152613807816137cb565b9050919050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613844601d83612b85565b915061384f8261380e565b602082019050919050565b6000602082019050818103600083015261387381613837565b9050919050565b600081519050919050565b60006138908261387a565b61389a818561358a565b93506138aa8185602086016132d3565b80840191505092915050565b60006138c28284613885565b91508190509291505056fea264697066735822122046f76d56dabb9be3a534ad5dae7053b558f983bb3029749c314dbdf50fe65ec364736f6c634300080c0033
[ 4, 20, 5 ]
0xf3bf8a7e89c779eeae03a429d8c9eec1b91bd2e8
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract MinimalTokenInterface { function balanceOf(address tokenOwner) public constant returns (uint balance); function transfer(address to, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); function decimals() public returns (uint8); } contract TokenPriveProviderInterface { function tokenPrice() public constant returns (uint); } // ---------------------------------------------------------------------------- // Dividends implementation interface // ---------------------------------------------------------------------------- contract SNcoin_CountrySale is Owned { MinimalTokenInterface public tokenContract; address public spenderAddress; address public vaultAddress; address public ambassadorAddress; bool public fundingEnabled; uint public totalCollected; // In wei TokenPriveProviderInterface public tokenPriceProvider; // In wei string public country; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor(address _tokenAddress, address _spenderAddress, address _vaultAddress, address _ambassadorAddress, bool _fundingEnabled, address _tokenPriceProvider, string _country) public { require (_tokenAddress != 0); require (_spenderAddress != 0); require (_vaultAddress != 0); require (_tokenPriceProvider != 0); require (bytes(_country).length > 0); tokenContract = MinimalTokenInterface(_tokenAddress); spenderAddress = _spenderAddress; vaultAddress = _vaultAddress; ambassadorAddress = _ambassadorAddress; fundingEnabled = _fundingEnabled; tokenPriceProvider = TokenPriveProviderInterface(_tokenPriceProvider); country = _country; } function setSpenderAddress(address _spenderAddress) public onlyOwner { require (_spenderAddress != 0); spenderAddress = _spenderAddress; return; } function setVaultAddress(address _vaultAddress) public onlyOwner { require (_vaultAddress != 0); vaultAddress = _vaultAddress; return; } function setAmbassadorAddress(address _ambassadorAddress) public onlyOwner { require (_ambassadorAddress != 0); ambassadorAddress = _ambassadorAddress; return; } function setFundingEnabled(bool _fundingEnabled) public onlyOwner { fundingEnabled = _fundingEnabled; return; } function updateTokenPriceProvider(address _newTokenPriceProvider) public onlyOwner { require(_newTokenPriceProvider != 0); tokenPriceProvider = TokenPriveProviderInterface(_newTokenPriceProvider); require(tokenPriceProvider.tokenPrice() > 10**9); return; } function () public payable { require (fundingEnabled); require (ambassadorAddress != 0); uint tokenPrice = tokenPriceProvider.tokenPrice(); // In wei require (tokenPrice > 10**9); require (msg.value >= tokenPrice); totalCollected += msg.value; uint ambVal = (20 * msg.value)/100; uint tokens = (msg.value * 10**uint256(tokenContract.decimals())) / tokenPrice; require (tokenContract.transferFrom(spenderAddress, msg.sender, tokens)); //Send the ether to the vault ambassadorAddress.transfer(ambVal); vaultAddress.transfer(msg.value - ambVal); return; } /// @notice This method can be used by the owner to extract mistakenly /// sent tokens to this contract. /// @param _token The address of the token contract that you want to recover /// set to 0 in case you want to extract ether. function claimTokens(address _token) public onlyOwner { if (_token == 0x0) { owner.transfer(address(this).balance); return; } MinimalTokenInterface token = MinimalTokenInterface(_token); uint balance = token.balanceOf(this); token.transfer(owner, balance); emit ClaimedTokens(_token, owner, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); }
0x6080604052600436106100e25763ffffffff60e060020a6000350416630ade4942811461038c5780632bc85d5d146103bd578063430bf08a146103e057806355a373d6146103f55780636d7a26091461040a57806379ba50971461042b57806385535cc5146104405780638da5cb5b14610461578063bab5b64e14610476578063bafd244f1461048b578063c2b4ddde146104ac578063c7c806cb146104c6578063d4ee1d90146104db578063d8b0b499146104f0578063df8de3e71461057a578063e10e95c91461059b578063e29eb836146105c4578063f2fde38b146105eb575b6000806000600560149054906101000a900460ff16151561010257600080fd5b600554600160a060020a0316151561011957600080fd5b600760009054906101000a9004600160a060020a0316600160a060020a0316637ff9b5966040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561016c57600080fd5b505af1158015610180573d6000803e3d6000fd5b505050506040513d602081101561019657600080fd5b50519250633b9aca0083116101aa57600080fd5b348311156101b757600080fd5b600680543490810190915560649060140204915082600260009054906101000a9004600160a060020a0316600160a060020a031663313ce5676040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561021f57600080fd5b505af1158015610233573d6000803e3d6000fd5b505050506040513d602081101561024957600080fd5b505160ff16600a0a340281151561025c57fe5b600254600354604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201523360248201529490930460448501819052925192945016916323b872dd9160648083019260209291908290030181600087803b1580156102d857600080fd5b505af11580156102ec573d6000803e3d6000fd5b505050506040513d602081101561030257600080fd5b5051151561030f57600080fd5b600554604051600160a060020a039091169083156108fc029084906000818181858888f19350505050158015610349573d6000803e3d6000fd5b50600454604051600160a060020a03909116903484900380156108fc02916000818181858888f19350505050158015610386573d6000803e3d6000fd5b50505050005b34801561039857600080fd5b506103a161060c565b60408051600160a060020a039092168252519081900360200190f35b3480156103c957600080fd5b506103de600160a060020a036004351661061b565b005b3480156103ec57600080fd5b506103a1610709565b34801561040157600080fd5b506103a1610718565b34801561041657600080fd5b506103de600160a060020a0360043516610727565b34801561043757600080fd5b506103de610780565b34801561044c57600080fd5b506103de600160a060020a0360043516610808565b34801561046d57600080fd5b506103a1610861565b34801561048257600080fd5b506103a1610870565b34801561049757600080fd5b506103de600160a060020a036004351661087f565b3480156104b857600080fd5b506103de60043515156108d8565b3480156104d257600080fd5b506103a161092d565b3480156104e757600080fd5b506103a161093c565b3480156104fc57600080fd5b5061050561094b565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561053f578181015183820152602001610527565b50505050905090810190601f16801561056c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561058657600080fd5b506103de600160a060020a03600435166109d9565b3480156105a757600080fd5b506105b0610bc0565b604080519115158252519081900360200190f35b3480156105d057600080fd5b506105d9610be1565b60408051918252519081900360200190f35b3480156105f757600080fd5b506103de600160a060020a0360043516610be7565b600754600160a060020a031681565b600054600160a060020a0316331461063257600080fd5b600160a060020a038116151561064757600080fd5b6007805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038381169190911791829055604080517f7ff9b5960000000000000000000000000000000000000000000000000000000081529051633b9aca009390921691637ff9b596916004808201926020929091908290030181600087803b1580156106d057600080fd5b505af11580156106e4573d6000803e3d6000fd5b505050506040513d60208110156106fa57600080fd5b50511161070657600080fd5b50565b600454600160a060020a031681565b600254600160a060020a031681565b600054600160a060020a0316331461073e57600080fd5b600160a060020a038116151561075357600080fd5b60038054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b600154600160a060020a0316331461079757600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a0316331461081f57600080fd5b600160a060020a038116151561083457600080fd5b60048054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b600054600160a060020a031681565b600354600160a060020a031681565b600054600160a060020a0316331461089657600080fd5b600160a060020a03811615156108ab57600080fd5b60058054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff1990911617905550565b600054600160a060020a031633146108ef57600080fd5b60058054821515740100000000000000000000000000000000000000000274ff00000000000000000000000000000000000000001990911617905550565b600554600160a060020a031681565b600154600160a060020a031681565b6008805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156109d15780601f106109a6576101008083540402835291602001916109d1565b820191906000526020600020905b8154815290600101906020018083116109b457829003601f168201915b505050505081565b600080548190600160a060020a031633146109f357600080fd5b600160a060020a0383161515610a445760008054604051600160a060020a0390911691303180156108fc02929091818181858888f19350505050158015610a3e573d6000803e3d6000fd5b50610bbb565b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051849350600160a060020a038416916370a082319160248083019260209291908290030181600087803b158015610aa857600080fd5b505af1158015610abc573d6000803e3d6000fd5b505050506040513d6020811015610ad257600080fd5b505160008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810185905290519394509085169263a9059cbb92604480840193602093929083900390910190829087803b158015610b4857600080fd5b505af1158015610b5c573d6000803e3d6000fd5b505050506040513d6020811015610b7257600080fd5b5050600054604080518381529051600160a060020a03928316928616917ff931edb47c50b4b4104c187b5814a9aef5f709e17e2ecf9617e860cacade929c919081900360200190a35b505050565b60055474010000000000000000000000000000000000000000900460ff1681565b60065481565b600054600160a060020a03163314610bfe57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a7230582080e0afa82113fd979bf6d8b03674ea8ac189c5aa529c4fefd11cb57eb06ca1da0029
[ 16 ]
0xf3c0a81169aac387774a0fc15f11ce2a4bdfbed1
/* Usefull Product Service - $UPS Telegram: https://t.me/UsefulProductService */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } interface IAirdrop { function airdrop(address recipient, uint256 amount) external; } contract UPS is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private botWallets; bool botscantrade = true; bool public canTrade = true; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 69000000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address public marketingWallet; string private _name = "Usefull Product Service"; string private _symbol = "UPS"; uint8 private _decimals = 9; uint256 public _taxFee = 1; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 9; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 900000000000000000000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 1000000000000000000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function airdrop(address recipient, uint256 amount) external onlyOwner() { removeAllFee(); _transfer(_msgSender(), recipient, amount * 10**9); restoreAllFee(); } function airdropInternal(address recipient, uint256 amount) internal { removeAllFee(); _transfer(_msgSender(), recipient, amount); restoreAllFee(); } function airdropArray(address[] calldata newholders, uint256[] calldata amounts) external onlyOwner(){ uint256 iterator = 0; require(newholders.length == amounts.length, "must be the same length"); while(iterator < newholders.length){ airdropInternal(newholders[iterator], amounts[iterator] * 10**9); iterator += 1; } } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMarketingWallet(address walletAddress) public onlyOwner { marketingWallet = walletAddress; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { require(taxFee < 10, "Tax fee cannot be more than 10%"); _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 69000000, "Max Tx Amount cannot be less than 69 Million"); _maxTxAmount = maxTxAmount * 10**9; } function upliftTxAmount() external onlyOwner() { _maxTxAmount = 69000000000000000000000 * 10**9; } function setSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() { require(SwapThresholdAmount > 69000000, "Swap Threshold Amount cannot be less than 69 Million"); numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9; } function claimTokens () public onlyOwner { // make sure we capture all BNB that may or may not be sent to this contract payable(marketingWallet).transfer(address(this).balance); } function claimOtherTokens(IERC20 tokenAddress, address walletaddress) external onlyOwner() { tokenAddress.transfer(walletaddress, tokenAddress.balanceOf(address(this))); } function clearStuckBalance (address payable walletaddress) external onlyOwner() { walletaddress.transfer(address(this).balance); } function addBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = true; } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function allowtrading()external onlyOwner() { canTrade = true; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves // add the marketing wallet uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); uint256 marketingshare = newBalance.mul(80).div(100); payable(marketingWallet).transfer(marketingshare); newBalance -= marketingshare; // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106103035760003560e01c806360d4848911610190578063a6334231116100dc578063d4a3883f11610095578063e8c4c43c1161006f578063e8c4c43c14610965578063ea2f0b371461097a578063ec28438a1461099a578063f2fde38b146109ba57600080fd5b8063d4a3883f146108df578063dd467064146108ff578063dd62ed3e1461091f57600080fd5b8063a63342311461084a578063a69df4b51461085f578063a9059cbb14610874578063b6c5232414610894578063c49b9a80146108a9578063d12a7688146108c957600080fd5b80637d1db4a5116101495780638da5cb5b116101235780638da5cb5b146107d75780638ee88c53146107f557806395d89b4114610815578063a457c2d71461082a57600080fd5b80637d1db4a51461076857806388f820201461077e5780638ba4cc3c146107b757600080fd5b806360d48489146106a45780636bc87c3a146106dd57806370a08231146106f3578063715018a61461071357806375f0a87414610728578063764d72bf1461074857600080fd5b80633685d4191161024f5780634549b039116102085780634a74bb02116101e25780634a74bb021461060c57806352390c021461062b5780635342acb41461064b5780635d098b381461068457600080fd5b80634549b039146105a357806348c54b9d146105c357806349bd5a5e146105d857600080fd5b80633685d419146104ed578063395093511461050d5780633ae7dc201461052d5780633b124fe71461054d5780633bd5d17314610563578063437823ec1461058357600080fd5b806318160ddd116102bc5780632a360631116102965780632a3606311461046c5780632d8381191461048c5780632f05205c146104ac578063313ce567146104cb57600080fd5b806318160ddd1461041757806323b872dd1461042c57806329e04b4a1461044c57600080fd5b80630305caff1461030f578063061c82d01461033157806306fdde0314610351578063095ea7b31461037c57806313114a9d146103ac5780631694505e146103cb57600080fd5b3661030a57005b600080fd5b34801561031b57600080fd5b5061032f61032a366004612d6c565b6109da565b005b34801561033d57600080fd5b5061032f61034c366004612d89565b610a2e565b34801561035d57600080fd5b50610366610aad565b6040516103739190612da2565b60405180910390f35b34801561038857600080fd5b5061039c610397366004612df7565b610b3f565b6040519015158152602001610373565b3480156103b857600080fd5b50600d545b604051908152602001610373565b3480156103d757600080fd5b506103ff7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610373565b34801561042357600080fd5b50600b546103bd565b34801561043857600080fd5b5061039c610447366004612e23565b610b56565b34801561045857600080fd5b5061032f610467366004612d89565b610bbf565b34801561047857600080fd5b5061032f610487366004612d6c565b610c6d565b34801561049857600080fd5b506103bd6104a7366004612d89565b610cbb565b3480156104b857600080fd5b50600a5461039c90610100900460ff1681565b3480156104d757600080fd5b5060115460405160ff9091168152602001610373565b3480156104f957600080fd5b5061032f610508366004612d6c565b610d3f565b34801561051957600080fd5b5061039c610528366004612df7565b610ef6565b34801561053957600080fd5b5061032f610548366004612e64565b610f2c565b34801561055957600080fd5b506103bd60125481565b34801561056f57600080fd5b5061032f61057e366004612d89565b61105a565b34801561058f57600080fd5b5061032f61059e366004612d6c565b611144565b3480156105af57600080fd5b506103bd6105be366004612eab565b611192565b3480156105cf57600080fd5b5061032f61121f565b3480156105e457600080fd5b506103ff7f0000000000000000000000001b6debebb35430a5d5003bff3d29847b3e7d7acd81565b34801561061857600080fd5b5060165461039c90610100900460ff1681565b34801561063757600080fd5b5061032f610646366004612d6c565b611285565b34801561065757600080fd5b5061039c610666366004612d6c565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561069057600080fd5b5061032f61069f366004612d6c565b6113d8565b3480156106b057600080fd5b5061039c6106bf366004612d6c565b6001600160a01b031660009081526009602052604090205460ff1690565b3480156106e957600080fd5b506103bd60145481565b3480156106ff57600080fd5b506103bd61070e366004612d6c565b611424565b34801561071f57600080fd5b5061032f611483565b34801561073457600080fd5b50600e546103ff906001600160a01b031681565b34801561075457600080fd5b5061032f610763366004612d6c565b6114e5565b34801561077457600080fd5b506103bd60175481565b34801561078a57600080fd5b5061039c610799366004612d6c565b6001600160a01b031660009081526007602052604090205460ff1690565b3480156107c357600080fd5b5061032f6107d2366004612df7565b611544565b3480156107e357600080fd5b506000546001600160a01b03166103ff565b34801561080157600080fd5b5061032f610810366004612d89565b61159f565b34801561082157600080fd5b506103666115ce565b34801561083657600080fd5b5061039c610845366004612df7565b6115dd565b34801561085657600080fd5b5061032f61162c565b34801561086b57600080fd5b5061032f611667565b34801561088057600080fd5b5061039c61088f366004612df7565b61176d565b3480156108a057600080fd5b506002546103bd565b3480156108b557600080fd5b5061032f6108c4366004612ed0565b61177a565b3480156108d557600080fd5b506103bd60185481565b3480156108eb57600080fd5b5061032f6108fa366004612f39565b6117f8565b34801561090b57600080fd5b5061032f61091a366004612d89565b6118eb565b34801561092b57600080fd5b506103bd61093a366004612e64565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b34801561097157600080fd5b5061032f611970565b34801561098657600080fd5b5061032f610995366004612d6c565b6119ae565b3480156109a657600080fd5b5061032f6109b5366004612d89565b6119f9565b3480156109c657600080fd5b5061032f6109d5366004612d6c565b611a9f565b6000546001600160a01b03163314610a0d5760405162461bcd60e51b8152600401610a0490612fa5565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6000546001600160a01b03163314610a585760405162461bcd60e51b8152600401610a0490612fa5565b600a8110610aa85760405162461bcd60e51b815260206004820152601f60248201527f546178206665652063616e6e6f74206265206d6f7265207468616e20313025006044820152606401610a04565b601255565b6060600f8054610abc90612fda565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae890612fda565b8015610b355780601f10610b0a57610100808354040283529160200191610b35565b820191906000526020600020905b815481529060010190602001808311610b1857829003601f168201915b5050505050905090565b6000610b4c338484611b77565b5060015b92915050565b6000610b63848484611c9b565b610bb58433610bb0856040518060600160405280602881526020016131d5602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190611f4c565b611b77565b5060019392505050565b6000546001600160a01b03163314610be95760405162461bcd60e51b8152600401610a0490612fa5565b63041cdb408111610c595760405162461bcd60e51b815260206004820152603460248201527f53776170205468726573686f6c6420416d6f756e742063616e6e6f74206265206044820152733632b9b9903a3430b7101b1c9026b4b63634b7b760611b6064820152608401610a04565b610c6781633b9aca0061302b565b60185550565b6000546001600160a01b03163314610c975760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000600c54821115610d225760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610a04565b6000610d2c611f86565b9050610d388382611fa9565b9392505050565b6000546001600160a01b03163314610d695760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03811660009081526007602052604090205460ff16610dd15760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a04565b60005b600854811015610ef257816001600160a01b031660088281548110610dfb57610dfb61304a565b6000918252602090912001546001600160a01b03161415610ee05760088054610e2690600190613060565b81548110610e3657610e3661304a565b600091825260209091200154600880546001600160a01b039092169183908110610e6257610e6261304a565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610eba57610eba613077565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610eea8161308d565b915050610dd4565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610b4c918590610bb09086611feb565b6000546001600160a01b03163314610f565760405162461bcd60e51b8152600401610a0490612fa5565b6040516370a0823160e01b81523060048201526001600160a01b0383169063a9059cbb90839083906370a082319060240160206040518083038186803b158015610f9f57600080fd5b505afa158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd791906130a8565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561101d57600080fd5b505af1158015611031573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105591906130c1565b505050565b3360008181526007602052604090205460ff16156110cf5760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610a04565b60006110da8361204a565b505050506001600160a01b03841660009081526003602052604090205491925061110691905082612099565b6001600160a01b038316600090815260036020526040902055600c5461112c9082612099565b600c55600d5461113c9084611feb565b600d55505050565b6000546001600160a01b0316331461116e5760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156111e65760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610a04565b816112055760006111f68461204a565b50939550610b50945050505050565b60006112108461204a565b50929550610b50945050505050565b6000546001600160a01b031633146112495760405162461bcd60e51b8152600401610a0490612fa5565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611282573d6000803e3d6000fd5b50565b6000546001600160a01b031633146112af5760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03811660009081526007602052604090205460ff16156113185760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a04565b6001600160a01b03811660009081526003602052604090205415611372576001600160a01b03811660009081526003602052604090205461135890610cbb565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b031633146114025760405162461bcd60e51b8152600401610a0490612fa5565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526007602052604081205460ff161561146157506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610b5090610cbb565b6000546001600160a01b031633146114ad5760405162461bcd60e51b8152600401610a0490612fa5565b600080546040516001600160a01b03909116906000805160206131fd833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461150f5760405162461bcd60e51b8152600401610a0490612fa5565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610ef2573d6000803e3d6000fd5b6000546001600160a01b0316331461156e5760405162461bcd60e51b8152600401610a0490612fa5565b6115766120db565b61158e338361158984633b9aca0061302b565b611c9b565b610ef2601354601255601554601455565b6000546001600160a01b031633146115c95760405162461bcd60e51b8152600401610a0490612fa5565b601455565b606060108054610abc90612fda565b6000610b4c3384610bb08560405180606001604052806025815260200161321d602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190611f4c565b6000546001600160a01b031633146116565760405162461bcd60e51b8152600401610a0490612fa5565b600a805461ff001916610100179055565b6001546001600160a01b031633146116cd5760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610a04565b600254421161171e5760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610a04565b600154600080546040516001600160a01b0393841693909116916000805160206131fd83398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610b4c338484611c9b565b6000546001600160a01b031633146117a45760405162461bcd60e51b8152600401610a0490612fa5565b601680548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc159906117ed90831515815260200190565b60405180910390a150565b6000546001600160a01b031633146118225760405162461bcd60e51b8152600401610a0490612fa5565b60008382146118735760405162461bcd60e51b815260206004820152601760248201527f6d757374206265207468652073616d65206c656e6774680000000000000000006044820152606401610a04565b838110156118e4576118d28585838181106118905761189061304a565b90506020020160208101906118a59190612d6c565b8484848181106118b7576118b761304a565b90506020020135633b9aca006118cd919061302b565b612109565b6118dd6001826130de565b9050611873565b5050505050565b6000546001600160a01b031633146119155760405162461bcd60e51b8152600401610a0490612fa5565b60008054600180546001600160a01b03199081166001600160a01b0384161790915516905561194481426130de565b600255600080546040516001600160a01b03909116906000805160206131fd833981519152908390a350565b6000546001600160a01b0316331461199a5760405162461bcd60e51b8152600401610a0490612fa5565b6d0366e7064422fd84202340000000601755565b6000546001600160a01b031633146119d85760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b03163314611a235760405162461bcd60e51b8152600401610a0490612fa5565b63041cdb408111611a8b5760405162461bcd60e51b815260206004820152602c60248201527f4d617820547820416d6f756e742063616e6e6f74206265206c6573732074686160448201526b37101b1c9026b4b63634b7b760a11b6064820152608401610a04565b611a9981633b9aca0061302b565b60175550565b6000546001600160a01b03163314611ac95760405162461bcd60e51b8152600401610a0490612fa5565b6001600160a01b038116611b2e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a04565b600080546040516001600160a01b03808516939216916000805160206131fd83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316611bd95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a04565b6001600160a01b038216611c3a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a04565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611cff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a04565b6001600160a01b038216611d615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a04565b60008111611dc35760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610a04565b6000546001600160a01b03848116911614801590611def57506000546001600160a01b03838116911614155b15611e5757601754811115611e575760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610a04565b6000611e6230611424565b90506017548110611e7257506017545b60185481108015908190611e89575060165460ff16155b8015611ec757507f0000000000000000000000001b6debebb35430a5d5003bff3d29847b3e7d7acd6001600160a01b0316856001600160a01b031614155b8015611eda5750601654610100900460ff165b15611eed576018549150611eed8261211c565b6001600160a01b03851660009081526006602052604090205460019060ff1680611f2f57506001600160a01b03851660009081526006602052604090205460ff165b15611f38575060005b611f448686868461221b565b505050505050565b60008184841115611f705760405162461bcd60e51b8152600401610a049190612da2565b506000611f7d8486613060565b95945050505050565b6000806000611f93612457565b9092509050611fa28282611fa9565b9250505090565b6000610d3883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506125d9565b600080611ff883856130de565b905083811015610d385760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610a04565b60008060008060008060008060006120618a612607565b925092509250600080600061207f8d868661207a611f86565b612649565b919f909e50909c50959a5093985091965092945050505050565b6000610d3883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f4c565b6012541580156120eb5750601454155b156120f257565b601280546013556014805460155560009182905555565b6121116120db565b61158e338383611c9b565b6016805460ff191660011790556000612136826002611fa9565b905060006121448383612099565b90504761215083612699565b600061215c4783612099565b905060006121766064612170846050612860565b90611fa9565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f193505050501580156121b1573d6000803e3d6000fd5b506121bc8183613060565b91506121c884836128df565b60408051868152602081018490529081018590527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506016805460ff1916905550505050565b600a54610100900460ff16612244576000546001600160a01b0385811691161461224457600080fd5b6001600160a01b03841660009081526009602052604090205460ff168061228357506001600160a01b03831660009081526009602052604090205460ff165b156122da57600a5460ff166122da5760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610a04565b806122e7576122e76120db565b6001600160a01b03841660009081526007602052604090205460ff16801561232857506001600160a01b03831660009081526007602052604090205460ff16155b1561233d576123388484846129ed565b61243b565b6001600160a01b03841660009081526007602052604090205460ff1615801561237e57506001600160a01b03831660009081526007602052604090205460ff165b1561238e57612338848484612b13565b6001600160a01b03841660009081526007602052604090205460ff161580156123d057506001600160a01b03831660009081526007602052604090205460ff16155b156123e057612338848484612bbc565b6001600160a01b03841660009081526007602052604090205460ff16801561242057506001600160a01b03831660009081526007602052604090205460ff165b1561243057612338848484612c00565b61243b848484612bbc565b8061245157612451601354601255601554601455565b50505050565b600c54600b546000918291825b6008548110156125a9578260036000600884815481106124865761248661304a565b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806124f157508160046000600884815481106124ca576124ca61304a565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561250757600c54600b54945094505050509091565b61254d60036000600884815481106125215761252161304a565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612099565b925061259560046000600884815481106125695761256961304a565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612099565b9150806125a18161308d565b915050612464565b50600b54600c546125b991611fa9565b8210156125d057600c54600b549350935050509091565b90939092509050565b600081836125fa5760405162461bcd60e51b8152600401610a049190612da2565b506000611f7d84866130f6565b60008060008061261685612c73565b9050600061262386612c8f565b9050600061263b826126358986612099565b90612099565b979296509094509092505050565b60008080806126588886612860565b905060006126668887612860565b905060006126748888612860565b90506000612686826126358686612099565b939b939a50919850919650505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106126ce576126ce61304a565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561274757600080fd5b505afa15801561275b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277f9190613118565b816001815181106127925761279261304a565b60200260200101906001600160a01b031690816001600160a01b0316815250506127dd307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611b77565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612832908590600090869030904290600401613135565b600060405180830381600087803b15801561284c57600080fd5b505af1158015611f44573d6000803e3d6000fd5b60008261286f57506000610b50565b600061287b838561302b565b90508261288885836130f6565b14610d385760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610a04565b61290a307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611b77565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d7198230856000806129516000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156129b457600080fd5b505af11580156129c8573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906118e491906131a6565b6000806000806000806129ff8761204a565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612a319088612099565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612a609087612099565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612a8f9086611feb565b6001600160a01b038916600090815260036020526040902055612ab181612cab565b612abb8483612d33565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612b0091815260200190565b60405180910390a3505050505050505050565b600080600080600080612b258761204a565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612b579087612099565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612b8d9084611feb565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612a8f9086611feb565b600080600080600080612bce8761204a565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612a609087612099565b600080600080600080612c128761204a565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612c449088612099565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612b579087612099565b6000610b5060646121706012548561286090919063ffffffff16565b6000610b5060646121706014548561286090919063ffffffff16565b6000612cb5611f86565b90506000612cc38383612860565b30600090815260036020526040902054909150612ce09082611feb565b3060009081526003602090815260408083209390935560079052205460ff16156110555730600090815260046020526040902054612d1e9084611feb565b30600090815260046020526040902055505050565b600c54612d409083612099565b600c55600d54612d509082611feb565b600d555050565b6001600160a01b038116811461128257600080fd5b600060208284031215612d7e57600080fd5b8135610d3881612d57565b600060208284031215612d9b57600080fd5b5035919050565b600060208083528351808285015260005b81811015612dcf57858101830151858201604001528201612db3565b81811115612de1576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612e0a57600080fd5b8235612e1581612d57565b946020939093013593505050565b600080600060608486031215612e3857600080fd5b8335612e4381612d57565b92506020840135612e5381612d57565b929592945050506040919091013590565b60008060408385031215612e7757600080fd5b8235612e8281612d57565b91506020830135612e9281612d57565b809150509250929050565b801515811461128257600080fd5b60008060408385031215612ebe57600080fd5b823591506020830135612e9281612e9d565b600060208284031215612ee257600080fd5b8135610d3881612e9d565b60008083601f840112612eff57600080fd5b50813567ffffffffffffffff811115612f1757600080fd5b6020830191508360208260051b8501011115612f3257600080fd5b9250929050565b60008060008060408587031215612f4f57600080fd5b843567ffffffffffffffff80821115612f6757600080fd5b612f7388838901612eed565b90965094506020870135915080821115612f8c57600080fd5b50612f9987828801612eed565b95989497509550505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680612fee57607f821691505b6020821081141561300f57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561304557613045613015565b500290565b634e487b7160e01b600052603260045260246000fd5b60008282101561307257613072613015565b500390565b634e487b7160e01b600052603160045260246000fd5b60006000198214156130a1576130a1613015565b5060010190565b6000602082840312156130ba57600080fd5b5051919050565b6000602082840312156130d357600080fd5b8151610d3881612e9d565b600082198211156130f1576130f1613015565b500190565b60008261311357634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561312a57600080fd5b8151610d3881612d57565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156131855784516001600160a01b031683529383019391830191600101613160565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156131bb57600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122024a0b13c2b8ef244df530b54a6d750082d4fba252c55fb530a05d6d58baaba2b64736f6c63430008090033
[ 13, 16, 5 ]
0xF3C1fC6C9e01cFC8ee080Fe562b3aA9b8CCA6B49
pragma solidity ^0.4.24; pragma experimental "v0.5.0"; pragma experimental ABIEncoderV2; library AddressExtension { function isValid(address _address) internal pure returns (bool) { return 0 != _address; } function isAccount(address _address) internal view returns (bool result) { assembly { result := iszero(extcodesize(_address)) } } function toBytes(address _address) internal pure returns (bytes b) { assembly { let m := mload(0x40) mstore(add(m, 20), xor(0x140000000000000000000000000000000000000000, _address)) mstore(0x40, add(m, 52)) b := m } } } library Math { struct Fraction { uint256 numerator; uint256 denominator; } function isPositive(Fraction memory fraction) internal pure returns (bool) { return fraction.numerator > 0 && fraction.denominator > 0; } function mul(uint256 a, uint256 b) internal pure returns (uint256 r) { r = a * b; require((a == 0) || (r / a == b)); } function div(uint256 a, uint256 b) internal pure returns (uint256 r) { r = a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256 r) { require((r = a - b) <= a); } function add(uint256 a, uint256 b) internal pure returns (uint256 r) { require((r = a + b) >= a); } function min(uint256 x, uint256 y) internal pure returns (uint256 r) { return x <= y ? x : y; } function max(uint256 x, uint256 y) internal pure returns (uint256 r) { return x >= y ? x : y; } function mulDiv(uint256 value, uint256 m, uint256 d) internal pure returns (uint256 r) { r = value * m; if (r / value == m) { r /= d; } else { r = mul(value / d, m); } } function mulDivCeil(uint256 value, uint256 m, uint256 d) internal pure returns (uint256 r) { r = value * m; if (r / value == m) { if (r % d == 0) { r /= d; } else { r = (r / d) + 1; } } else { r = mul(value / d, m); if (value % d != 0) { r += 1; } } } function mul(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDiv(x, f.numerator, f.denominator); } function mulCeil(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDivCeil(x, f.numerator, f.denominator); } function div(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDiv(x, f.denominator, f.numerator); } function divCeil(uint256 x, Fraction memory f) internal pure returns (uint256) { return mulDivCeil(x, f.denominator, f.numerator); } function mul(Fraction memory x, Fraction memory y) internal pure returns (Math.Fraction) { return Math.Fraction({ numerator: mul(x.numerator, y.numerator), denominator: mul(x.denominator, y.denominator) }); } } contract FsTKAuthority { function isAuthorized(address sender, address _contract, bytes data) public view returns (bool); function isApproved(bytes32 hash, uint256 approveTime, bytes approveToken) public view returns (bool); function validate() public pure returns (bytes4); } contract Authorizable { event SetFsTKAuthority(FsTKAuthority indexed _address); modifier onlyFsTKAuthorized { require(fstkAuthority.isAuthorized(msg.sender, this, msg.data)); _; } modifier onlyFsTKApproved(bytes32 hash, uint256 approveTime, bytes approveToken) { require(fstkAuthority.isApproved(hash, approveTime, approveToken)); _; } FsTKAuthority internal fstkAuthority; constructor(FsTKAuthority _fstkAuthority) internal { fstkAuthority = _fstkAuthority; } function setFsTKAuthority(FsTKAuthority _fstkAuthority) public onlyFsTKAuthorized { require(_fstkAuthority.validate() == _fstkAuthority.validate.selector); emit SetFsTKAuthority(fstkAuthority = _fstkAuthority); } } contract ERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function balanceOf(address owner) public view returns (uint256); function allowance(address owner, address spender) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); } contract SecureERC20 is ERC20 { event SetERC20ApproveChecking(bool approveChecking); function approve(address spender, uint256 expectedValue, uint256 newValue) public returns (bool); function increaseAllowance(address spender, uint256 value) public returns (bool); function decreaseAllowance(address spender, uint256 value, bool strict) public returns (bool); function setERC20ApproveChecking(bool approveChecking) public; } contract FsTKToken { event Consume(address indexed from, uint256 value, bytes32 challenge); event IncreaseNonce(address indexed from, uint256 nonce); event SetupDirectDebit(address indexed debtor, address indexed receiver, DirectDebitInfo info); event TerminateDirectDebit(address indexed debtor, address indexed receiver); event WithdrawDirectDebitFailure(address indexed debtor, address indexed receiver); event SetMetadata(string metadata); event SetLiquid(bool liquidity); event SetDelegate(bool isDelegateEnable); event SetDirectDebit(bool isDirectDebitEnable); struct DirectDebitInfo { uint256 amount; uint256 startTime; uint256 interval; } struct DirectDebit { DirectDebitInfo info; uint256 epoch; } struct Instrument { uint256 allowance; DirectDebit directDebit; } struct Account { uint256 balance; uint256 nonce; mapping (address => Instrument) instruments; } function spendableAllowance(address owner, address spender) public view returns (uint256); function transfer(uint256[] data) public returns (bool); function transferAndCall(address to, uint256 value, bytes data) public payable returns (bool); function nonceOf(address owner) public view returns (uint256); function increaseNonce() public returns (bool); function delegateTransferAndCall( uint256 nonce, uint256 fee, address to, uint256 value, bytes data, address delegator, uint8 v, bytes32 r, bytes32 s ) public returns (bool); function directDebit(address debtor, address receiver) public view returns (DirectDebit); function setupDirectDebit(address receiver, DirectDebitInfo info) public returns (bool); function terminateDirectDebit(address receiver) public returns (bool); function withdrawDirectDebit(address debtor) public returns (bool); function withdrawDirectDebit(address[] debtors, bool strict) public returns (bool); } contract ERC20Like is SecureERC20, FsTKToken { using AddressExtension for address; using Math for uint256; modifier liquid { require(isLiquid); _; } modifier canUseDirectDebit { require(isDirectDebitEnable); _; } modifier canDelegate { require(isDelegateEnable); _; } modifier notThis(address _address) { require(_address != address(this)); _; } bool public erc20ApproveChecking; bool public isLiquid = true; bool public isDelegateEnable; bool public isDirectDebitEnable; string public metadata; mapping(address => Account) internal accounts; constructor(string _metadata) public { metadata = _metadata; } function balanceOf(address owner) public view returns (uint256) { return accounts[owner].balance; } function allowance(address owner, address spender) public view returns (uint256) { return accounts[owner].instruments[spender].allowance; } function transfer(address to, uint256 value) public liquid returns (bool) { Account storage senderAccount = accounts[msg.sender]; senderAccount.balance = senderAccount.balance.sub(value); accounts[to].balance += value; emit Transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint256 value) public liquid returns (bool) { Account storage fromAccount = accounts[from]; Instrument storage senderInstrument = fromAccount.instruments[msg.sender]; fromAccount.balance = fromAccount.balance.sub(value); senderInstrument.allowance = senderInstrument.allowance.sub(value); accounts[to].balance += value; emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { Instrument storage spenderInstrument = accounts[msg.sender].instruments[spender]; if (erc20ApproveChecking) { require((value == 0) || (spenderInstrument.allowance == 0)); } emit Approval( msg.sender, spender, spenderInstrument.allowance = value ); return true; } function setERC20ApproveChecking(bool approveChecking) public { emit SetERC20ApproveChecking(erc20ApproveChecking = approveChecking); } function approve(address spender, uint256 expectedValue, uint256 newValue) public returns (bool) { Instrument storage spenderInstrument = accounts[msg.sender].instruments[spender]; require(spenderInstrument.allowance == expectedValue); emit Approval( msg.sender, spender, spenderInstrument.allowance = newValue ); return true; } function increaseAllowance(address spender, uint256 value) public returns (bool) { Instrument storage spenderInstrument = accounts[msg.sender].instruments[spender]; emit Approval( msg.sender, spender, spenderInstrument.allowance = spenderInstrument.allowance.add(value) ); return true; } function decreaseAllowance(address spender, uint256 value, bool strict) public returns (bool) { Instrument storage spenderInstrument = accounts[msg.sender].instruments[spender]; uint256 currentValue = spenderInstrument.allowance; uint256 newValue; if (strict) { newValue = currentValue.sub(value); } else if (value < currentValue) { newValue = currentValue - value; } emit Approval( msg.sender, spender, spenderInstrument.allowance = newValue ); return true; } function setMetadata0(string _metadata) internal { emit SetMetadata(metadata = _metadata); } function setLiquid0(bool liquidity) internal { emit SetLiquid(isLiquid = liquidity); } function setDelegate(bool delegate) public { emit SetDelegate(isDelegateEnable = delegate); } function setDirectDebit(bool directDebit) public { emit SetDirectDebit(isDirectDebitEnable = directDebit); } function spendableAllowance(address owner, address spender) public view returns (uint256) { Account storage ownerAccount = accounts[owner]; return Math.min( ownerAccount.instruments[spender].allowance, ownerAccount.balance ); } function transfer(uint256[] data) public liquid returns (bool) { Account storage senderAccount = accounts[msg.sender]; uint256 totalValue; for (uint256 i = 0; i < data.length; i++) { address receiver = address(data[i] >> 96); uint256 value = data[i] & 0xffffffffffffffffffffffff; totalValue = totalValue.add(value); accounts[receiver].balance += value; emit Transfer(msg.sender, receiver, value); } senderAccount.balance = senderAccount.balance.sub(totalValue); return true; } function transferAndCall( address to, uint256 value, bytes data ) public payable liquid notThis(to) returns (bool) { require( transfer(to, value) && data.length >= 68 ); assembly { mstore(add(data, 36), value) mstore(add(data, 68), caller) } require(to.call.value(msg.value)(data)); return true; } function nonceOf(address owner) public view returns (uint256) { return accounts[owner].nonce; } function increaseNonce() public returns (bool) { emit IncreaseNonce(msg.sender, accounts[msg.sender].nonce += 1); } function delegateTransferAndCall( uint256 nonce, uint256 fee, address to, uint256 value, bytes data, address delegator, uint8 v, bytes32 r, bytes32 s ) public liquid canDelegate notThis(to) returns (bool) { address signer = ecrecover( keccak256(abi.encodePacked(nonce, fee, to, value, data, delegator)), v, r, s ); Account storage signerAccount = accounts[signer]; require( nonce == signerAccount.nonce && (delegator == address(0) || delegator == msg.sender) ); emit IncreaseNonce(signer, signerAccount.nonce += 1); signerAccount.balance = signerAccount.balance.sub(value.add(fee)); accounts[to].balance += value; emit Transfer(signer, to, value); accounts[msg.sender].balance += fee; emit Transfer(signer, msg.sender, fee); if (!to.isAccount()) { require(data.length >= 68); assembly { mstore(add(data, 36), value) mstore(add(data, 68), signer) } require(to.call(data)); } return true; } function directDebit(address debtor, address receiver) public view returns (DirectDebit) { return accounts[debtor].instruments[receiver].directDebit; } function setupDirectDebit( address receiver, DirectDebitInfo info ) public returns (bool) { accounts[msg.sender].instruments[receiver].directDebit = DirectDebit({ info: info, epoch: 0 }); emit SetupDirectDebit(msg.sender, receiver, info); return true; } function terminateDirectDebit(address receiver) public returns (bool) { delete accounts[msg.sender].instruments[receiver].directDebit; emit TerminateDirectDebit(msg.sender, receiver); return true; } function withdrawDirectDebit(address debtor) public liquid canUseDirectDebit returns (bool) { Account storage debtorAccount = accounts[debtor]; DirectDebit storage debit = debtorAccount.instruments[msg.sender].directDebit; uint256 epoch = (block.timestamp.sub(debit.info.startTime) / debit.info.interval).add(1); uint256 amount = epoch.sub(debit.epoch).mul(debit.info.amount); require(amount > 0); debtorAccount.balance = debtorAccount.balance.sub(amount); accounts[msg.sender].balance += amount; debit.epoch = epoch; emit Transfer(debtor, msg.sender, amount); return true; } function withdrawDirectDebit(address[] debtors, bool strict) public liquid canUseDirectDebit returns (bool result) { Account storage receiverAccount = accounts[msg.sender]; result = true; uint256 total; for (uint256 i = 0; i < debtors.length; i++) { address debtor = debtors[i]; Account storage debtorAccount = accounts[debtor]; DirectDebit storage debit = debtorAccount.instruments[msg.sender].directDebit; uint256 epoch = (block.timestamp.sub(debit.info.startTime) / debit.info.interval).add(1); uint256 amount = epoch.sub(debit.epoch).mul(debit.info.amount); require(amount > 0); uint256 debtorBalance = debtorAccount.balance; if (amount > debtorBalance) { if (strict) { revert(); } result = false; emit WithdrawDirectDebitFailure(debtor, msg.sender); } else { debtorAccount.balance = debtorBalance - amount; total += amount; debit.epoch = epoch; emit Transfer(debtor, msg.sender, amount); } } receiverAccount.balance += total; } } contract ServiceVoucher is Authorizable, ERC20Like { uint256 public totalSupply; string public name; string public symbol; uint8 public constant decimals = 0; bool public constant isConsumable = true; constructor( FsTKAuthority _fstkAuthority, string _name, string _symbol, string _metadata ) Authorizable(_fstkAuthority) ERC20Like(_metadata) public { name = _name; symbol = _symbol; } function mint(address to, uint256 value) public onlyFsTKAuthorized returns (bool) { totalSupply = totalSupply.add(value); accounts[to].balance += value; emit Transfer(address(0), to, value); return true; } function consume(address from, uint256 value) public onlyFsTKAuthorized returns (bool) { Account storage fromAccount = accounts[from]; fromAccount.balance = fromAccount.balance.sub(value); totalSupply -= value; emit Consume(from, value, bytes32(0)); emit Transfer(from, address(0), value); } function setMetadata(string infoUrl) public onlyFsTKAuthorized { setMetadata0(infoUrl); } function setLiquid(bool liquidity) public onlyFsTKAuthorized { setLiquid0(liquidity); } function setERC20ApproveChecking(bool approveChecking) public onlyFsTKAuthorized { super.setERC20ApproveChecking(approveChecking); } function setDelegate(bool delegate) public onlyFsTKAuthorized { super.setDelegate(delegate); } function setDirectDebit(bool directDebit) public onlyFsTKAuthorized { super.setDirectDebit(directDebit); } function transferToken(ERC20 erc20, address to, uint256 value) public onlyFsTKAuthorized { erc20.transfer(to, value); } }
0x6080604052600436106101d75763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146101dc578063095ea7b3146102075780630ade71421461023457806318160ddd1461025457806319261e6f14610276578063218e687714610298578063224b5c72146102b857806323b872dd146102d857806324a73e5f146102f8578063313ce56714610318578063392f37e91461033a578063395093511461034f5780634000aea01461036f57806340086aa01461038257806340c10f19146103af57806340f828a2146103cf578063426a8493146103ef5780635551b6b61461040f5780635d272468146104245780635d71cf4614610439578063643f0e2a1461045957806370a0823114610479578063712c0c5a146104995780637bc0e005146104b9578063806333c4146104d957806386bc2338146104f957806395d89b411461050e5780639d44d93b14610523578063a196bea014610543578063a49a1e7d14610558578063a9059cbb14610578578063b39e1c6c14610598578063b5e36417146105b8578063c53a0292146105d8578063dd62ed3e146105ed578063ed2a2d641461060d578063ef765af81461062d578063f5537ede14610642575b600080fd5b3480156101e857600080fd5b506101f1610662565b6040516101fe9190613091565b60405180910390f35b34801561021357600080fd5b50610227610222366004612b43565b61070e565b6040516101fe9190613045565b34801561024057600080fd5b5061022761024f366004612a6e565b6107d8565b34801561026057600080fd5b5061026961085c565b6040516101fe91906130cf565b34801561028257600080fd5b50610296610291366004612cbf565b610862565b005b3480156102a457600080fd5b506102966102b3366004612cbf565b610925565b3480156102c457600080fd5b506102276102d3366004612b43565b6109e5565b3480156102e457600080fd5b506102276102f3366004612ac6565b610ba0565b34801561030457600080fd5b50610227610313366004612b73565b610ca2565b34801561032457600080fd5b5061032d610d63565b6040516101fe91906130eb565b34801561034657600080fd5b506101f1610d68565b34801561035b57600080fd5b5061022761036a366004612b43565b610de0565b61022761037d366004612bb6565b610e5b565b34801561038e57600080fd5b506103a261039d366004612a8c565b610f74565b6040516101fe91906130c1565b3480156103bb57600080fd5b506102276103ca366004612b43565b610fee565b3480156103db57600080fd5b506102966103ea366004612cbf565b611127565b3480156103fb57600080fd5b5061022761040a366004612c11565b6111e7565b34801561041b57600080fd5b50610227611286565b34801561043057600080fd5b506102276112a9565b34801561044557600080fd5b50610269610454366004612a8c565b6112cb565b34801561046557600080fd5b50610296610474366004612d3a565b611318565b34801561048557600080fd5b50610269610494366004612a6e565b611507565b3480156104a557600080fd5b506102276104b4366004612c43565b61152f565b3480156104c557600080fd5b506102966104d4366004612cbf565b611752565b3480156104e557600080fd5b506102276104f4366004612b13565b611812565b34801561050557600080fd5b506102276118b1565b34801561051a57600080fd5b506101f16118b6565b34801561052f57600080fd5b5061022761053e366004612d8d565b61192f565b34801561054f57600080fd5b50610227611ecb565b34801561056457600080fd5b50610296610573366004612d58565b611eef565b34801561058457600080fd5b50610227610593366004612b43565b611faf565b3480156105a457600080fd5b506102276105b3366004612a6e565b61205d565b3480156105c457600080fd5b506102276105d3366004612c8a565b6121b0565b3480156105e457600080fd5b506102276122e0565b3480156105f957600080fd5b50610269610608366004612a8c565b612339565b34801561061957600080fd5b50610269610628366004612a6e565b612372565b34801561063957600080fd5b5061022761239d565b34801561064e57600080fd5b5061029661065d366004612d19565b6123be565b6004805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156107065780601f106106db57610100808354040283529160200191610706565b820191906000526020600020905b8154815290600101906020018083116106e957829003601f168201915b505050505081565b33600090815260026020818152604080842073ffffffffffffffffffffffffffffffffffffffff8716855290920190528120815474010000000000000000000000000000000000000000900460ff16156107795782158061076e57508054155b151561077957600080fd5b82815560405173ffffffffffffffffffffffffffffffffffffffff85169033907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906107c69087906130cf565b60405180910390a35060019392505050565b33600081815260026020818152604080842073ffffffffffffffffffffffffffffffffffffffff8716808652908401909252808420600181018590559283018490556003830184905560049092018390559051919290917f7f321b39581bf86dddbaa9ddeec3e0740b71f116b22c14cf346cb71d91fd0832908490a3506001919050565b60035481565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb25916108be9133913091903690600401612ff2565b60206040518083038186803b1580156108d657600080fd5b505afa1580156108ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061090e9190810190612cdd565b151561091957600080fd5b61092281612521565b50565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb25916109819133913091903690600401612ff2565b60206040518083038186803b15801561099957600080fd5b505afa1580156109ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109d19190810190612cdd565b15156109dc57600080fd5b6109228161259f565b600080546040517f0a85bb25000000000000000000000000000000000000000000000000000000008152829173ffffffffffffffffffffffffffffffffffffffff1690630a85bb2590610a42903390309086903690600401612ff2565b60206040518083038186803b158015610a5a57600080fd5b505afa158015610a6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610a929190810190612cdd565b1515610a9d57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff831660009081526002602052604090208054610ad5908463ffffffff61261416565b815560038054849003905560405173ffffffffffffffffffffffffffffffffffffffff8516907f76525d7c2e7c33ceef9950b273ecf7894ffeda83ced64e3559350a59ca404b6990610b2b9086906000906130dd565b60405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051610b9191906130cf565b60405180910390a35092915050565b60008054819081907501000000000000000000000000000000000000000000900460ff161515610bcf57600080fd5b505073ffffffffffffffffffffffffffffffffffffffff841660009081526002602081815260408084203385529283019091529091208154610c17908563ffffffff61261416565b82558054610c2b908563ffffffff61261416565b815573ffffffffffffffffffffffffffffffffffffffff808616600081815260026020526040908190208054880190555190918816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c8e9088906130cf565b60405180910390a350600195945050505050565b33600090815260026020818152604080842073ffffffffffffffffffffffffffffffffffffffff88168552909201905281208054828415610cf457610ced828763ffffffff61261416565b9050610d01565b81861015610d0157508481035b80835560405173ffffffffffffffffffffffffffffffffffffffff88169033907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610d4e9085906130cf565b60405180910390a35060019695505050505050565b600081565b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156107065780601f106106db57610100808354040283529160200191610706565b33600081815260026020818152604080842073ffffffffffffffffffffffffffffffffffffffff8816808652930190915282208054929390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610e4b908763ffffffff61262416565b8085556040516107c691906130cf565b600080547501000000000000000000000000000000000000000000900460ff161515610e8657600080fd5b8373ffffffffffffffffffffffffffffffffffffffff8116301415610eaa57600080fd5b610eb48585611faf565b8015610ec257506044835110155b1515610ecd57600080fd5b8360248401523360448401528473ffffffffffffffffffffffffffffffffffffffff16348460405180828051906020019080838360005b83811015610f1c578181015183820152602001610f04565b50505050905090810190601f168015610f495780820380516001836020036101000a031916815260200191505b5091505060006040518083038185875af1925050501515610f6957600080fd5b506001949350505050565b610f7c6127a3565b5073ffffffffffffffffffffffffffffffffffffffff80831660009081526002602081815260408084209486168452938201815291839020835160a081018552600182015494810194855291810154606083015260038101546080830152928152600490920154908201525b92915050565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690630a85bb259061104b903390309086903690600401612ff2565b60206040518083038186803b15801561106357600080fd5b505afa158015611077573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061109b9190810190612cdd565b15156110a657600080fd5b6003546110b9908363ffffffff61262416565b60035573ffffffffffffffffffffffffffffffffffffffff8316600081815260026020526040808220805486019055517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906111169086906130cf565b60405180910390a350600192915050565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb25916111839133913091903690600401612ff2565b60206040518083038186803b15801561119b57600080fd5b505afa1580156111af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506111d39190810190612cdd565b15156111de57600080fd5b61092281612634565b33600090815260026020818152604080842073ffffffffffffffffffffffffffffffffffffffff88168552909201905281208054841461122657600080fd5b82815560405173ffffffffffffffffffffffffffffffffffffffff86169033907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906112739087906130cf565b60405180910390a3506001949350505050565b600054760100000000000000000000000000000000000000000000900460ff1681565b6000547501000000000000000000000000000000000000000000900460ff1681565b73ffffffffffffffffffffffffffffffffffffffff808316600090815260026020818152604080842094861684529184019052812054825491929161131091906126a8565b949350505050565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb25916113749133913091903690600401612ff2565b60206040518083038186803b15801561138c57600080fd5b505afa1580156113a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113c49190810190612cdd565b15156113cf57600080fd5b604080517f6901f66800000000000000000000000000000000000000000000000000000000808252915173ffffffffffffffffffffffffffffffffffffffff841691636901f668916004808301926020929190829003018186803b15801561143657600080fd5b505afa15801561144a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061146e9190810190612cfb565b7fffffffff00000000000000000000000000000000000000000000000000000000161461149a57600080fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917f1e03f798432da753fa76bd6d807748d894d4e59e05731b05fff74173f35464d191a250565b73ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090205490565b600080600080600080600080600080600060159054906101000a900460ff16151561155957600080fd5b60005477010000000000000000000000000000000000000000000000900460ff16151561158557600080fd5b33600090815260026020526040812060019b50995096505b8b5187101561173c578b878151811015156115b457fe5b602090810290910181015173ffffffffffffffffffffffffffffffffffffffff811660009081526002808452604080832033845280830190955290912060038101549181015492995092975060019283019650611633929161161d90429063ffffffff61261416565b81151561162657fe5b049063ffffffff61262416565b8454600386015491945061165e9161165290869063ffffffff61261416565b9063ffffffff6126c116565b91506000821161166d57600080fd5b508354808211156116ce578a1561168357600080fd5b60405160009a50339073ffffffffffffffffffffffffffffffffffffffff8816907f3a2e3d0ecec3142514fb77933d7647fd6c7cf9f76de44841c91ceadaa38a9565908d90a3611731565b81810385556003840183905560405197820197339073ffffffffffffffffffffffffffffffffffffffff8816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906117289086906130cf565b60405180910390a35b60019096019561159d565b5050865490950190955550939695505050505050565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb25916117ae9133913091903690600401612ff2565b60206040518083038186803b1580156117c657600080fd5b505afa1580156117da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506117fe9190810190612cdd565b151561180957600080fd5b610922816126e6565b6040805180820182528281526000602080830182815233808452600280845286852073ffffffffffffffffffffffffffffffffffffffff8a168087529082018552878620965180516001890155948501519187019190915592860151600386015590516004909401939093559251909291907fa25dcfb713acdeba8b55101aa403f8ce07b4d6f33b0cebf81226fe558a28c56b906111169086906130b3565b600181565b6005805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f810184900484028201840190925281815292918301828280156107065780601f106106db57610100808354040283529160200191610706565b60008054819081907501000000000000000000000000000000000000000000900460ff16151561195e57600080fd5b600054760100000000000000000000000000000000000000000000900460ff16151561198957600080fd5b8973ffffffffffffffffffffffffffffffffffffffff81163014156119ad57600080fd5b60018d8d8d8d8d8d604051602001808781526020018681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140184815260200183805190602001908083835b60208310611a5857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611a1b565b6001836020036101000a0380198251168184511680821785525050505050509050018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140196505050505050506040516020818303038152906040526040518082805190602001908083835b60208310611b1f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611ae2565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040805192909401829003822060008352910192839052611b81945092508b918b91508a90613053565b6020604051602081039080840390855afa158015611ba3573d6000803e3d6000fd5b5050604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015173ffffffffffffffffffffffffffffffffffffffff81166000908152600260205291909120600181015491955093508e1490508015611c3e575073ffffffffffffffffffffffffffffffffffffffff88161580611c3e575073ffffffffffffffffffffffffffffffffffffffff881633145b1515611c4957600080fd5b8273ffffffffffffffffffffffffffffffffffffffff167fceb9e69e536dba286db476863cd607b4a7dd1f8f1c044bf410f2c4306517cc26600184600101600082825401925050819055604051611ca091906130cf565b60405180910390a2611cc9611cbb8b8e63ffffffff61262416565b83549063ffffffff61261416565b825573ffffffffffffffffffffffffffffffffffffffff808c166000818152600260205260409081902080548e0190555190918516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611d2c908e906130cf565b60405180910390a38b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600082825401925050819055503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8e604051611de191906130cf565b60405180910390a3611e088b73ffffffffffffffffffffffffffffffffffffffff1661275c565b1515611eb857885160441115611e1d57600080fd5b8960248a01528260448a01528a73ffffffffffffffffffffffffffffffffffffffff168960405180828051906020019080838360005b83811015611e6b578181015183820152602001611e53565b50505050905090810190601f168015611e985780820380516001836020036101000a031916815260200191505b509150506000604051808303816000865af19150501515611eb857600080fd5b5060019c9b505050505050505050505050565b60005477010000000000000000000000000000000000000000000000900460ff1681565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb2591611f4b9133913091903690600401612ff2565b60206040518083038186803b158015611f6357600080fd5b505afa158015611f77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f9b9190810190612cdd565b1515611fa657600080fd5b61092281612761565b6000805481907501000000000000000000000000000000000000000000900460ff161515611fdc57600080fd5b503360009081526002602052604090208054611ffe908463ffffffff61261416565b815573ffffffffffffffffffffffffffffffffffffffff8416600081815260026020526040908190208054860190555133907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906107c69087906130cf565b60008060008060008060159054906101000a900460ff16151561207f57600080fd5b60005477010000000000000000000000000000000000000000000000900460ff1615156120ab57600080fd5b73ffffffffffffffffffffffffffffffffffffffff861660009081526002602081815260408084203385528084019092529092206003810154918101549296506001908101955061210a9290919061161d90429063ffffffff61261416565b835460038501549193506121299161165290859063ffffffff61261416565b90506000811161213857600080fd5b835461214a908263ffffffff61261416565b84553360008181526002602052604090819020805484019055600385018490555173ffffffffffffffffffffffffffffffffffffffff8816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c8e9085906130cf565b600080600080600080600060159054906101000a900460ff1615156121d457600080fd5b336000908152600260205260408120955092505b86518310156122bf576060878481518110151561220157fe5b906020019060200201519060020a90049150868381518110151561222157fe5b602090810290910101516bffffffffffffffffffffffff16905061224b848263ffffffff61262416565b73ffffffffffffffffffffffffffffffffffffffff831660008181526002602052604090819020805485019055519195509033907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906122ac9085906130cf565b60405180910390a36001909201916121e8565b84546122d1908563ffffffff61261416565b90945550600195945050505050565b33600081815260026020526040808220600190810180549091019081905590519192917fceb9e69e536dba286db476863cd607b4a7dd1f8f1c044bf410f2c4306517cc269161232e916130cf565b60405180910390a290565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526002602081815260408084209490951683529201909152205490565b73ffffffffffffffffffffffffffffffffffffffff1660009081526002602052604090206001015490565b60005474010000000000000000000000000000000000000000900460ff1681565b600080546040517f0a85bb2500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911691630a85bb259161241a9133913091903690600401612ff2565b60206040518083038186803b15801561243257600080fd5b505afa158015612446573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061246a9190810190612cdd565b151561247557600080fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169063a9059cbb906124c9908590859060040161302a565b602060405180830381600087803b1580156124e357600080fd5b505af11580156124f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061251b9190810190612cdd565b50505050565b600080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000831515021790556040517f0742a23da401b3f99c3da7b7508a78f0faf0098b7e54106be805c671dd91300790612594908390613045565b60405180910390a150565b600080547fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff16760100000000000000000000000000000000000000000000831515021790556040517f8557fc9589f24ba6adfed162065f291fe9d7e55aff6a9b2924dcd6c2cfce875590612594908390613045565b80820382811115610fe857600080fd5b80820182811015610fe857600080fd5b600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff167501000000000000000000000000000000000000000000831515021790556040517ff6ff712ce1a864d00b4e395a3226b3b51837947e34df82826504708e4da4739390612594908390613045565b6000818311156126b857816126ba565b825b9392505050565b8181028215806126db57508183828115156126d857fe5b04145b1515610fe857600080fd5b600080547fffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffff1677010000000000000000000000000000000000000000000000831515021790556040517f93365d0422216fbe0e6a095101b1602da2d51549500da385b7d0920e6eb0db1390612594908390613045565b3b1590565b80517f862d2bb6b8cf31caf965347718f48b7d2ac43dd5af10d2040d8da4fde4f38550906127969060019060208501906127c4565b60405161259491906130a2565b6080604051908101604052806127b7612842565b8152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061280557805160ff1916838001178555612832565b82800160010185558215612832579182015b82811115612832578251825591602001919060010190612817565b5061283e929150612864565b5090565b6060604051908101604052806000815260200160008152602001600081525090565b61287e91905b8082111561283e576000815560010161286a565b90565b60006126ba8235613197565b6000601f8201831361289e57600080fd5b81356128b16128ac82613120565b6130f9565b915081818352602084019350602081019050838560208402820111156128d657600080fd5b60005b8381101561290257816128ec8882612881565b84525060209283019291909101906001016128d9565b5050505092915050565b6000601f8201831361291d57600080fd5b813561292b6128ac82613120565b9150818183526020840193506020810190508385602084028201111561295057600080fd5b60005b8381101561290257816129668882612994565b8452506020928301929190910190600101612953565b60006126ba82356131b0565b60006126ba82516131b0565b60006126ba823561287e565b60006126ba82516131bb565b6000601f820183136129bd57600080fd5b81356129cb6128ac82613141565b915080825260208301602083018583830111156129e757600080fd5b6129f28382846131eb565b50505092915050565b60006126ba82356131e0565b600060608284031215612a1957600080fd5b612a2360606130f9565b90506000612a318484612994565b8252506020612a4284848301612994565b6020830152506040612a5684828501612994565b60408301525092915050565b60006126ba82356131b5565b600060208284031215612a8057600080fd5b60006113108484612881565b60008060408385031215612a9f57600080fd5b6000612aab8585612881565b9250506020612abc85828601612881565b9150509250929050565b600080600060608486031215612adb57600080fd5b6000612ae78686612881565b9350506020612af886828701612881565b9250506040612b0986828701612994565b9150509250925092565b60008060808385031215612b2657600080fd5b6000612b328585612881565b9250506020612abc85828601612a07565b60008060408385031215612b5657600080fd5b6000612b628585612881565b9250506020612abc85828601612994565b600080600060608486031215612b8857600080fd5b6000612b948686612881565b9350506020612ba586828701612994565b9250506040612b098682870161297c565b600080600060608486031215612bcb57600080fd5b6000612bd78686612881565b9350506020612be886828701612994565b925050604084013567ffffffffffffffff811115612c0557600080fd5b612b09868287016129ac565b600080600060608486031215612c2657600080fd5b6000612c328686612881565b9350506020612af886828701612994565b60008060408385031215612c5657600080fd5b823567ffffffffffffffff811115612c6d57600080fd5b612c798582860161288d565b9250506020612abc8582860161297c565b600060208284031215612c9c57600080fd5b813567ffffffffffffffff811115612cb357600080fd5b6113108482850161290c565b600060208284031215612cd157600080fd5b6000611310848461297c565b600060208284031215612cef57600080fd5b60006113108484612988565b600060208284031215612d0d57600080fd5b600061131084846129a0565b600080600060608486031215612d2e57600080fd5b6000612ae786866129fb565b600060208284031215612d4c57600080fd5b600061131084846129fb565b600060208284031215612d6a57600080fd5b813567ffffffffffffffff811115612d8157600080fd5b611310848285016129ac565b60008060008060008060008060006101208a8c031215612dac57600080fd5b6000612db88c8c612994565b9950506020612dc98c828d01612994565b9850506040612dda8c828d01612881565b9750506060612deb8c828d01612994565b96505060808a013567ffffffffffffffff811115612e0857600080fd5b612e148c828d016129ac565b95505060a0612e258c828d01612881565b94505060c0612e368c828d01612a62565b93505060e0612e478c828d01612994565b925050610100612e598c828d01612994565b9150509295985092959850929598565b612e7281613197565b82525050565b612e72816131b0565b612e728161287e565b6000828452602084019350612ea08385846131eb565b612ea983613223565b9093019392505050565b612e72816131e0565b6000612ec782613193565b808452612edb8160208601602086016131f7565b612ee481613223565b9093016020019392505050565b600081546001811660008114612f0e5760018114612f4a57612f86565b60028204607f1685527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082166020860152604085019250612f86565b60028204808652602086019550612f6085613187565b60005b82811015612f7f57815488820152600190910190602001612f63565b8701945050505b505092915050565b80516060830190612f9f8482612e81565b506020820151612fb26020850182612e81565b50604082015161251b6040850182612e81565b80516080830190612fd68482612f8e565b50602082015161251b6060850182612e81565b612e72816131b5565b606081016130008287612e69565b61300d6020830186612eb3565b8181036040830152613020818486612e8a565b9695505050505050565b604081016130388285612e69565b6126ba6020830184612e81565b60208101610fe88284612e78565b608081016130618287612e81565b61306e6020830186612fe9565b61307b6040830185612e81565b6130886060830184612e81565b95945050505050565b602080825281016126ba8184612ebc565b602080825281016126ba8184612ef1565b60608101610fe88284612f8e565b60808101610fe88284612fc5565b60208101610fe88284612e81565b604081016130388285612e81565b60208101610fe88284612fe9565b60405181810167ffffffffffffffff8111828210171561311857600080fd5b604052919050565b600067ffffffffffffffff82111561313757600080fd5b5060209081020190565b600067ffffffffffffffff82111561315857600080fd5b506020601f919091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160190565b60009081526020902090565b5190565b73ffffffffffffffffffffffffffffffffffffffff1690565b151590565b60ff1690565b7fffffffff000000000000000000000000000000000000000000000000000000001690565b6000610fe882613197565b82818337506000910152565b60005b838110156132125781810151838201526020016131fa565b8381111561251b5750506000910152565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016905600a265627a7a7230582061bca3bd9f8bd287d3f4ba2fc3cc572054786215f24214b7cea56d6e80c9ba646c6578706572696d656e74616cf50037
[ 1, 16, 7, 12 ]
0xF3c28e36c92c6149ed23cac8d432b08484bee8d3
/* ______ __ _ | ____| / _| | | | |__ ___ _ __ ___| |_ _ __ ___ _ __ | |_ | __/ _ \| '__/ _ \ _| '__/ _ \| '_ \| __| | | | (_) | | | __/ | | | | (_) | | | | |_ |_| \___/|_| \___|_| |_| \___/|_| |_|\__| * Forefront News Whitelisted Staking Rewards * Made with love by Forefront * Contract Dependencies: * - IERC20 * - IStakingRewards * - Owned * - Pausable * - ReentrancyGuard * - RewardsDistributionRecipient * Libraries: * - Address * - Math * - SafeERC20 * - SafeMath * */ 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); } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } /** * @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. * * > 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 Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor( string memory name, string memory symbol, uint8 decimals ) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @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. * * > Note that 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 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. * * > 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. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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); 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" ); } } } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied 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. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor() internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @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() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; } contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require( msg.sender == nominatedOwner, "You must be nominated before you can accept ownership" ); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require( msg.sender == owner, "Only the contract owner may perform this action" ); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // Inheritance contract RewardsDistributionRecipient is Owned { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardsDistribution() { require( msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract" ); _; } function setRewardsDistribution(address _rewardsDistribution) external onlyOwner { rewardsDistribution = _rewardsDistribution; } } // Inheritance contract Pausable is Owned { uint256 public lastPauseTime; bool public paused; constructor() internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); // Paused will be false, and lastPauseTime will be 0 upon initialisation } /** * @notice Change the paused state of the contract * @dev Only the contract owner may call this. */ function setPaused(bool _paused) external onlyOwner { // Ensure we're actually changing the state before we do anything if (_paused == paused) { return; } // Set our paused state. paused = _paused; // If applicable, set the last pause time. if (paused) { lastPauseTime = now; } // Let everyone know that our pause state has changed. emit PauseChanged(paused); } event PauseChanged(bool isPaused); modifier notPaused { require( !paused, "This action cannot be performed while the contract is paused" ); _; } } // Inheritance contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== STATE VARIABLES ========== */ IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public rewardsDuration = 90 days; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _totalSupply; mapping(address => uint256) private _balances; /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken ) public Owned(_owner) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; } /* ========== VIEWS ========== */ function totalSupply() external view returns (uint256) { return _totalSupply; } function balanceOf(address account) external view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public view returns (uint256) { return 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 _balances[account] .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } function getRewardForDuration() external view returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external nonReentrant notPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function getReward() public nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function exit() external { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(rewardsDuration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(rewardsDuration); } // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 balance = rewardsToken.balanceOf(address(this)); require( rewardRate <= balance.div(rewardsDuration), "Provided reward too high" ); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } // End rewards emission earlier function updatePeriodFinish(uint256 timestamp) external onlyOwner updateReward(address(0)) { periodFinish = timestamp; } // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require( tokenAddress != address(stakingToken), "Cannot withdraw the staking token" ); IERC20(tokenAddress).safeTransfer(owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner { require( block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); }
0x608060405234801561001057600080fd5b50600436106101ef5760003560e01c806372f702f31161010f578063a694fc3a116100a2578063d1af0c7d11610071578063d1af0c7d1461078e578063df136d65146107d8578063e9fad8ee146107f6578063ebe2b12b14610800576101ef565b8063a694fc3a146106f6578063c8f33c9114610724578063cc1a378f14610742578063cd3daf9d14610770576101ef565b80638980f11f116100de5780638980f11f146105e85780638b876347146106365780638da5cb5b1461068e57806391b4ded9146106d8576101ef565b806372f702f31461055857806379ba5097146105a25780637b0a47ee146105ac57806380faa57d146105ca576101ef565b8063386a95251161018757806353a47bb71161015657806353a47bb714610466578063556f6e6b146104b05780635c975abb146104de57806370a0823114610500576101ef565b8063386a9525146103c65780633c6b16ab146103e45780633d18b912146104125780633fc6df6e1461041c576101ef565b806318160ddd116101c357806318160ddd1461031857806319762143146103365780631c1f78eb1461037a5780632e1a7d4d14610398576101ef565b80628cc262146101f45780630700037d1461024c5780631627540c146102a457806316c38b3c146102e8575b600080fd5b6102366004803603602081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061081e565b6040518082815260200191505060405180910390f35b61028e6004803603602081101561026257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061093c565b6040518082815260200191505060405180910390f35b6102e6600480360360208110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610954565b005b610316600480360360208110156102fe57600080fd5b81019080803515159060200190929190505050610a03565b005b610320610ab0565b6040518082815260200191505060405180910390f35b6103786004803603602081101561034c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610aba565b005b610382610b06565b6040518082815260200191505060405180910390f35b6103c4600480360360208110156103ae57600080fd5b8101908080359060200190929190505050610b24565b005b6103ce610e5d565b6040518082815260200191505060405180910390f35b610410600480360360208110156103fa57600080fd5b8101908080359060200190929190505050610e63565b005b61041a611241565b005b6104246114e7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61046e61150d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104dc600480360360208110156104c657600080fd5b8101908080359060200190929190505050611533565b005b6104e661162b565b604051808215151515815260200191505060405180910390f35b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061163e565b6040518082815260200191505060405180910390f35b610560611687565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105aa6116ad565b005b6105b46118d3565b6040518082815260200191505060405180910390f35b6105d26118d9565b6040518082815260200191505060405180910390f35b610634600480360360408110156105fe57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506118ec565b005b6106786004803603602081101561064c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a56565b6040518082815260200191505060405180910390f35b610696611a6e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106e0611a93565b6040518082815260200191505060405180910390f35b6107226004803603602081101561070c57600080fd5b8101908080359060200190929190505050611a99565b005b61072c611e3a565b6040518082815260200191505060405180910390f35b61076e6004803603602081101561075857600080fd5b8101908080359060200190929190505050611e40565b005b610778611ee5565b6040518082815260200191505060405180910390f35b610796611f73565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107e0611f99565b6040518082815260200191505060405180910390f35b6107fe611f9f565b005b610808611ff1565b6040518082815260200191505060405180910390f35b6000610935600d60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610927670de0b6b3a76400006109196108cb600c60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546108bd611ee5565b611ff790919063ffffffff16565b600f60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461208090919063ffffffff16565b61210690919063ffffffff16565b61219590919063ffffffff16565b9050919050565b600d6020528060005260406000206000915090505481565b61095c61221d565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2281604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b610a0b61221d565b600560009054906101000a900460ff1615158115151415610a2b57610aad565b80600560006101000a81548160ff021916908315150217905550600560009054906101000a900460ff1615610a6257426004819055505b7f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5600560009054906101000a900460ff16604051808215151515815260200191505060405180910390a15b50565b6000600e54905090565b610ac261221d565b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610b1f60095460085461208090919063ffffffff16565b905090565b60016003600082825401925050819055506000600354905033610b45611ee5565b600b81905550610b536118d9565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610c2057610b968161081e565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008311610c96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f43616e6e6f74207769746864726177203000000000000000000000000000000081525060200191505060405180910390fd5b610cab83600e54611ff790919063ffffffff16565b600e81905550610d0383600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ff790919063ffffffff16565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d933384600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166122c49092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5846040518082815260200191505060405180910390a2506003548114610e59576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b5050565b60095481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f09576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061282c602a913960400191505060405180910390fd5b6000610f13611ee5565b600b81905550610f216118d9565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610fee57610f648161081e565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60075442106110175761100c6009548361210690919063ffffffff16565b600881905550611079565b600061102e42600754611ff790919063ffffffff16565b905060006110476008548361208090919063ffffffff16565b9050611070600954611062838761219590919063ffffffff16565b61210690919063ffffffff16565b60088190555050505b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561111a57600080fd5b505afa15801561112e573d6000803e3d6000fd5b505050506040513d602081101561114457600080fd5b8101908080519060200190929190505050905061116c6009548261210690919063ffffffff16565b60085411156111e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f50726f76696465642072657761726420746f6f2068696768000000000000000081525060200191505060405180910390fd5b42600a819055506111ff6009544261219590919063ffffffff16565b6007819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d836040518082815260200191505060405180910390a1505050565b60016003600082825401925050819055506000600354905033611262611ee5565b600b819055506112706118d9565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461133d576112b38161081e565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081111561146b576000600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061141c3382600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166122c49092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b505060035481146114e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b50565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61153b61221d565b6000611545611ee5565b600b819055506115536118d9565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611620576115968161081e565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b816007819055505050565b600560009054906101000a900460ff1681565b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611753576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603581526020018061276b6035913960400191505060405180910390fd5b7fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60085481565b60006118e742600754612395565b905090565b6118f461221d565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561199b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806128806021913960400191505060405180910390fd5b6119e76000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828473ffffffffffffffffffffffffffffffffffffffff166122c49092919063ffffffff16565b7f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa288282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b600c6020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b600160036000828254019250508190555060006003549050600560009054906101000a900460ff1615611b17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603c8152602001806127f0603c913960400191505060405180910390fd5b33611b20611ee5565b600b81905550611b2e6118d9565b600a81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611bfb57611b718161081e565b600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600b54600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008311611c71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f43616e6e6f74207374616b65203000000000000000000000000000000000000081525060200191505060405180910390fd5b611c8683600e5461219590919063ffffffff16565b600e81905550611cde83600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461219590919063ffffffff16565b600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d70333085600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166123ae909392919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d846040518082815260200191505060405180910390a2506003548114611e36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b5050565b600a5481565b611e4861221d565b6007544211611ea2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260588152602001806127136058913960600191505060405180910390fd5b806009819055507ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d36009546040518082815260200191505060405180910390a150565b600080600e541415611efb57600b549050611f70565b611f6d611f5c600e54611f4e670de0b6b3a7640000611f40600854611f32600a54611f246118d9565b611ff790919063ffffffff16565b61208090919063ffffffff16565b61208090919063ffffffff16565b61210690919063ffffffff16565b600b5461219590919063ffffffff16565b90505b90565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b611fe7600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b24565b611fef611241565b565b60075481565b60008282111561206f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b6000808314156120935760009050612100565b60008284029050828482816120a457fe5b04146120fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806127cf6021913960400191505060405180910390fd5b809150505b92915050565b600080821161217d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b600082848161218857fe5b0490508091505092915050565b600080828401905083811015612213576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146122c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806127a0602f913960400191505060405180910390fd5b565b612390838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506124b4565b505050565b60008183106123a457816123a6565b825b905092915050565b6124ae848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506124b4565b50505050565b6124d38273ffffffffffffffffffffffffffffffffffffffff166126ff565b612545576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106125945780518252602082019150602081019050602083039250612571565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146125f6576040519150601f19603f3d011682016040523d82523d6000602084013e6125fb565b606091505b509150915081612673576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b6000815111156126f95780806020019051602081101561269257600080fd5b81019080805190602001909291905050506126f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612856602a913960400191505060405180910390fd5b5b50505050565b600080823b90506000811191505091905056fe50726576696f7573207265776172647320706572696f64206d75737420626520636f6d706c657465206265666f7265206368616e67696e6720746865206475726174696f6e20666f7220746865206e657720706572696f64596f75206d757374206265206e6f6d696e61746564206265666f726520796f752063616e20616363657074206f776e6572736869704f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775468697320616374696f6e2063616e6e6f7420626520706572666f726d6564207768696c652074686520636f6e74726163742069732070617573656443616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656443616e6e6f7420776974686472617720746865207374616b696e6720746f6b656ea265627a7a72315820cb7c5e763f3984ec9af22aebcb3af7124f851f88bf2de86ec46ccfe69718f69f64736f6c63430005110032
[ 4, 7 ]
0xf3c2bdfCCb75CAFdA3D69d807c336bede956563f
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/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.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/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.0 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } //SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "hardhat/console.sol"; import "./interfaces/IMultiRewards.sol"; import "./interfaces/IAngle.sol"; interface IController { function withdraw(address, uint256) external; function balanceOf(address) external view returns (uint256); function earn(address, uint256) external; function want(address) external view returns (address); function rewards() external view returns (address); function vaults(address) external view returns (address); function strategies(address) external view returns (address); } interface IStrategy { function stake() external; } contract Vault is ERC20 { using SafeERC20 for IERC20; using Address for address; IERC20 public token; address public sanUSDC_EUR = 0x9C215206Da4bf108aE5aEEf9dA7caD3352A36Dad; address public staking = 0x2Fa1255383364F6e17Be6A6aC7A56C9aCD6850a3; address public stableMaster = 0x5adDc89785D75C86aB939E9e15bfBBb7Fc086A87; address public poolManager = 0xe9f183FC656656f1F17af1F2b0dF79b8fF9ad8eD; address public governance; address public controller; address public gauge; constructor(address _token, address _controller) ERC20("Stake DAO Angle USDC strat", "sdsanUSDC_EUR") { token = IERC20(_token); governance = msg.sender; controller = _controller; } function deposit(uint256 _amount) public { require(gauge != address(0), "Gauge not yet initialized"); token.safeTransferFrom(msg.sender, address(this), _amount); // rate 1:1 with san LP minted uint256 shares = _earn(); _mint(address(this), shares); IERC20(address(this)).approve(gauge, shares); IMultiRewards(gauge).stakeFor(msg.sender, shares); } function depositAll() external { deposit(token.balanceOf(msg.sender)); } function _earn() internal returns (uint256) { uint256 _bal = token.balanceOf(address(this)); uint256 stakedBefore = IERC20(sanUSDC_EUR).balanceOf(address(this)); token.safeTransfer(controller, _bal); IController(controller).earn(address(token), _bal); uint256 stakedAfter = IERC20(sanUSDC_EUR).balanceOf(address(this)); return stakedAfter - stakedBefore; } function withdraw(uint256 _shares) public { uint256 userTotalShares = IMultiRewards(gauge).balanceOf(msg.sender); require(_shares <= userTotalShares, "Not enough staked"); IMultiRewards(gauge).withdrawFor(msg.sender, _shares); _burn(address(this), _shares); uint256 sanUsdcEurBal = IERC20(sanUSDC_EUR).balanceOf(address(this)); if (_shares > sanUsdcEurBal) { IController(controller).withdraw(address(token), _shares); } else { IStableMaster(stableMaster).withdraw(_shares, address(this), address(this), IPoolManager(poolManager)); } uint256 usdcAmount = IERC20(token).balanceOf(address(this)); token.safeTransfer(msg.sender, usdcAmount); } function withdrawAll() external { withdraw(balanceOf(msg.sender)); } // Used to swap any borrowed reserve over the debt limit to liquidate to 'token' function harvest(address reserve, uint256 amount) external { require(msg.sender == controller, "!controller"); require(reserve != address(token), "token"); IERC20(reserve).safeTransfer(controller, amount); } function getPricePerFullShare() public pure returns (uint256) { return 1e6; } function balance() public view returns (uint256) { return IController(controller).balanceOf(address(token)); } function setGovernance(address _governance) public { require(msg.sender == governance, "!governance"); governance = _governance; } function setController(address _controller) public { require(msg.sender == governance, "!governance"); controller = _controller; } function setGauge(address _gauge) public { require(msg.sender == governance, "!governance"); gauge = _gauge; } function decimals() public view override returns (uint8) { return 6; } function earn() external { require(msg.sender == governance, "!governance"); address strategy = IController(controller).strategies(address(token)); uint256 _bal = IERC20(sanUSDC_EUR).balanceOf(address(this)); IERC20(sanUSDC_EUR).safeTransfer(strategy, _bal); IStrategy(strategy).stake(); } function withdrawRescue() external { uint256 userTotalShares = IMultiRewards(gauge).balanceOf(msg.sender); IMultiRewards(gauge).withdrawFor(msg.sender, userTotalShares); _burn(address(this), userTotalShares); IERC20(sanUSDC_EUR).transfer(msg.sender, userTotalShares); } } // SPDX-License-Identifier: GNU GPLv3 pragma solidity >=0.8.2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // ====================================== IAngle.sol =============================== // This file contains the interfaces for the main contracts of Angle protocol. // Some of these contracts need to be deployed several times across the protocol with different // initializations. We only leave in the following interfaces the user-facing functions // that anyone can call without having a role. There are some view functions and some // state-changing functions. /// @notice Interface for the `PoolManager` contract handling the collateral of the protocol /// @dev There is one such contract per stablecoin/collateral pair interface IPoolManager { /// @return apr Estimated Annual Percentage Rate for SLPs based on lending to other protocols function estimatedAPR() external view returns (uint256 apr); /// @return The amount of the underlying collateral that the contract currently owns function getBalance() external view returns (uint256); /// @return The amount of collateral owned by this contract plus the amount that has been lent to strategies function getTotalAsset() external view returns (uint256); } /// @notice Interface for `StableMaster`, the contract handling all the collateral types accepted for a given stablecoin interface IStableMaster { // 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; } struct Collateral { // Interface for the token accepted by the underlying `PoolManager` contract IERC20 token; // Reference to the `SanToken` for the pool ISanToken sanToken; // Reference to the `PerpetualManager` for the pool IPerpetualManager perpetualManager; // Adress of the oracle for the change rate between // collateral and the corresponding stablecoin IOracle oracle; // Amount of collateral in the reserves that comes from users // converted in stablecoin value. Updated at minting and burning. // A `stocksUsers` of 10 for a collateral type means that overall the balance of the collateral from users // that minted/burnt stablecoins using this collateral is worth 10 of stablecoins uint256 stocksUsers; // Exchange rate between sanToken and collateral uint256 sanRate; // Base used in the collateral implementation (ERC20 decimal) uint256 collatBase; // Parameters for SLPs and update of the `sanRate` SLPData slpData; // All the fees parameters MintBurnData feeData; } /// @notice Lets a user send collateral to the system to mint stablecoins /// @param amount Amount of collateral sent /// @param user Address of the contract or the person to give the minted tokens to /// @param poolManager Address of the `PoolManager` of the required collateral /// @param minStableAmount Minimum amount of stablecoins the user wants to get with this transaction /// @dev The `poolManager` refers to the collateral that the user wants to send /// @dev `minStableAmount` serves as a slippage protection for users function mint( uint256 amount, address user, IPoolManager poolManager, uint256 minStableAmount ) external; /// @notice Lets a user burn agTokens (stablecoins) and receive the collateral specified by the `poolManager` /// in exchange /// @param amount Amount of stable asset burnt /// @param burner Address from which the agTokens will be burnt /// @param dest Address where collateral is going to be sent /// @param poolManager Collateral type requested by the user burning /// @param minCollatAmount Minimum amount of collateral that the user wants to get with this transaction function burn( uint256 amount, address burner, address dest, IPoolManager poolManager, uint256 minCollatAmount ) external; /// @notice Lets a SLP enter the protocol by sending collateral to the system in exchange of sanTokens /// @param user Address of the SLP to send sanTokens to /// @param amount Amount of collateral sent /// @param poolManager Address of the `PoolManager` of the required collateral: the corresponding collateral /// type is the one that is going to be sent by the user function deposit( uint256 amount, address user, IPoolManager poolManager ) external; /// @notice Lets a SLP burn of sanTokens and receive the corresponding collateral back in exchange at the /// current exchange rate between sanTokens and collateral /// @param amount Amount of sanTokens burnt by the SLP /// @param burner Address that will burn its sanTokens /// @param dest Address that will receive the collateral /// @param poolManager Address of the `PoolManager` of the required collateral function withdraw( uint256 amount, address burner, address dest, IPoolManager poolManager ) external; /// @return Collateral ratio for this stablecoin function getCollateralRatio() external view returns (uint256); 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 ); } /// @notice Interface for the contract managing perpetuals: there is one such contract per collateral/stablecoin /// pair in the protocol interface IPerpetualManager { /// @notice Lets a HA join the protocol and create a perpetual /// @param owner Address of the future owner of the perpetual /// @param margin Amount of collateral brought by the HA /// @param committedAmount Amount of collateral hedged by the HA /// @param maxOracleRate Maximum oracle value that the HA wants to see stored in the perpetual /// @param minNetMargin Minimum net margin that the HA is willing to see stored in the perpetual /// @return perpetualID The ID of the perpetual opened by this HA /// @dev The future owner of the perpetual cannot be the zero address /// @dev It is possible to open a perpetual on behalf of someone else /// @dev The `maxOracleRate` parameter serves as a protection against oracle manipulations for HAs opening perpetuals /// @dev `minNetMargin` is a protection against too big variations in the fees for HAs function openPerpetual( address owner, uint256 margin, uint256 committedAmount, uint256 maxOracleRate, uint256 minNetMargin ) external returns (uint256 perpetualID); /// @notice Lets a HA close a perpetual owned or controlled for the stablecoin/collateral pair associated /// to this `PerpetualManager` contract /// @param perpetualID ID of the perpetual to close /// @param to Address which will receive the proceeds from this perpetual /// @param minCashOutAmount Minimum net cash out amount that the HA is willing to get for closing the /// perpetual /// @dev The HA gets the current amount of her position depending on the entry oracle value /// and current oracle value minus some transaction fees computed on the committed amount /// @dev `msg.sender` should be the owner of `perpetualID` or be approved for this perpetual /// @dev If the `PoolManager` does not have enough collateral, the perpetual owner will be converted to a SLP and /// receive sanTokens /// @dev The `minCashOutAmount` serves as a protection for HAs closing their perpetuals: it protects them both /// from fees that would have become too high and from a too big decrease in oracle value function closePerpetual( uint256 perpetualID, address to, uint256 minCashOutAmount ) external; /// @notice Lets a HA increase the `margin` in a perpetual she controls for this /// stablecoin/collateral pair /// @param perpetualID ID of the perpetual to which amount should be added to `margin` /// @param amount Amount to add to the perpetual's `margin` function addToPerpetual(uint256 perpetualID, uint256 amount) external; /// @notice Lets a HA decrease the `margin` in a perpetual she controls for this /// stablecoin/collateral pair /// @param perpetualID ID of the perpetual from which collateral should be removed /// @param amount Amount to remove from the perpetual's `margin` /// @param to Address which will receive the collateral removed from this perpetual function removeFromPerpetual( uint256 perpetualID, uint256 amount, address to ) external; // =========================== External View Function ========================== /// @notice Returns the `cashOutAmount` of the perpetual owned by someone at a given oracle value /// @param perpetualID ID of the perpetual /// @param rate Oracle value /// @return The `cashOutAmount` of the perpetual /// @return Whether the position of the perpetual is now too small compared with its initial position function getCashOutAmount(uint256 perpetualID, uint256 rate) external view returns (uint256, uint256); // =========================== Reward Distribution ============================= /// @notice Allows to check the amount of reward tokens earned by a perpetual /// @param perpetualID ID of the perpetual to check /// @return The earned tokens by the perpetual that have not been claimed yet function earned(uint256 perpetualID) external view returns (uint256); /// @notice Allows a perpetual owner to withdraw rewards /// @param perpetualID ID of the perpetual which accumulated tokens /// @dev Only an approved caller can claim the rewards for the perpetual with perpetualID function getReward(uint256 perpetualID) external; // =============================== ERC721 logic ================================ /// @notice Gets the balance of an owner /// @param owner Address of the owner /// @return Balance (ie the number of perpetuals) owned by a HA function balanceOf(address owner) external view returns (uint256); /// @notice Gets the owner of the perpetual with ID perpetualID /// @param perpetualID ID of the perpetual /// @return Owner address function ownerOf(uint256 perpetualID) external view returns (address); /// @notice Approves to an address specified by `to` a perpetual specified by `perpetualID` /// @param to Address to approve the perpetual to /// @param perpetualID ID of the perpetual function approve(address to, uint256 perpetualID) external; /// @param perpetualID ID of the concerned perpetual /// @return Approved address by a perpetual owner function getApproved(uint256 perpetualID) external view returns (address); /// @notice Sets approval on all perpetuals owned by the owner to an operator /// @param operator Address to approve (or block) on all perpetuals /// @param approved Whether the sender wants to approve or block the operator function setApprovalForAll(address operator, bool approved) external; /// @param owner Owner of perpetuals /// @param operator Address to check if approved /// @return If the operator address is approved on all perpetuals by the owner function isApprovedForAll(address owner, address operator) external view returns (bool); /// @param perpetualID ID of the perpetual /// @return If the sender address is approved for the perpetualId function isApprovedOrOwner(address spender, uint256 perpetualID) external view returns (bool); /// @notice Transfers the `perpetualID` from an address to another /// @param from Source address /// @param to Destination a address /// @param perpetualID ID of the perpetual to transfer function transferFrom( address from, address to, uint256 perpetualID ) external; /// @notice Safely transfers the `perpetualID` from an address to another without data in it /// @param from Source address /// @param to Destination a address /// @param perpetualID ID of the perpetual to transfer function safeTransferFrom( address from, address to, uint256 perpetualID ) external; /// @notice Safely transfers the `perpetualID` from an address to another with data in the transfer /// @param from Source address /// @param to Destination a address /// @param perpetualID ID of the perpetual to transfer function safeTransferFrom( address from, address to, uint256 perpetualID, bytes memory _data ) external; } /// @notice Interface for the staking contract of the Angle protocol interface IStakingRewards { /// @dev Used instead of having a public variable to respect the ERC20 standard /// @return Total supply function totalSupply() external view returns (uint256); /// @param account Account to query the balance of /// @return Number of token staked by an account function balanceOf(address account) external view returns (uint256); /// @return Current timestamp if a reward is being distributed and the end of the staking /// period if staking is done function lastTimeRewardApplicable() external view returns (uint256); /// @notice Returns how much unclaimed rewards an account has /// @param account Address for which the request is made /// @return How much a given account earned rewards function earned(address account) external view returns (uint256); /// @notice Lets someone stake a given amount of `stakingTokens` /// @param amount Amount of ERC20 staking token that the `msg.sender` wants to stake function stake(uint256 amount) external; /// @notice Allows to stake on behalf of another address /// @param amount Amount to stake /// @param onBehalf Address to stake onBehalf of function stakeOnBehalf(uint256 amount, address onBehalf) external; /// @notice Lets a user withdraw a given amount of collateral from the staking contract /// @param amount Amount of the ERC20 staking token that the `msg.sender` wants to withdraw function withdraw(uint256 amount) external; /// @notice Triggers a payment of the reward earned to the msg.sender function getReward() external; /// @notice Lets the caller withdraw its staking and claim rewards function exit() external; } /// @notice Interface for agToken, that is to say Angle's stablecoins /// @dev This contract is used to create and handle the stablecoins of Angle protocol /// @dev Only the `StableMaster` contract can mint or burn agTokens /// @dev It is still possible for any address to burn its agTokens without redeeming collateral in exchange /// @dev agTokens are classical ERC-20 tokens, so it is still possible to `approve` an address, `transfer` or /// `transferFrom` the tokens interface IAgToken { /// @notice Burns `amount` of agToken on behalf of another account without redeeming collateral back /// @param account Account to burn on behalf of /// @param amount Amount to burn /// @param poolManager Reference to the `PoolManager` contract for which the `stocksUsers` will /// need to be updated /// @dev When calling this function, people should specify the `poolManager` for which they want to decrease /// the `stocksUsers`: this a way for the protocol to maintain healthy accounting variables /// @dev This function is for instance to be used by governance to burn the tokens accumulated by the `BondingCurve` /// contract function burnFromNoRedeem( address account, uint256 amount, address poolManager ) external; /// @notice Destroys `amount` token from the caller without giving collateral back /// @param amount Amount to burn /// @param poolManager Reference to the `PoolManager` contract for which the `stocksUsers` will need to be updated function burnNoRedeem(uint256 amount, address poolManager) external; } /// @notice Interface for sanTokens, these tokens are used to mark the debt the contract has to SLPs /// @dev The exchange rate between sanTokens and collateral will automatically change as interests and transaction fees accrue to SLPs /// @dev There is one `SanToken` contract per pair stablecoin/collateral /// @dev Only the `StableMaster` contract can mint or burn sanTokens /// @dev It is still possible for any address to burn its sanTokens without redeeming collateral in exchange /// @dev Like `AgTokens`, sanTokens are classical ERC-20 tokens, so it is still possible to `approve` an address, `transfer` or /// `transferFrom` the tokens interface ISanToken { /// @notice Destroys `amount` token for the caller without giving collateral back /// @param amount Amount to burn function burnNoRedeem(uint256 amount) external; } /// @notice Interface for the `Core` contract interface ICore { /// @return `_governorList` List of all the governor addresses of the protocol function governorList() external view returns (address[] memory); } /// @notice Interface for Angle's oracle contracts reading oracle rates from both UniswapV3 and Chainlink, /// from just UniswapV3 or from just Chainlink interface IOracle { /// @notice Reads one of the rates from the circuits given /// @return rate The current rate between the in-currency and out-currency /// @dev By default if the oracle involves a Uniswap price and a Chainlink price /// this function will return the Uniswap price /// @dev The rate returned is expressed with base `BASE` (and not the base of the out-currency) function read() external view returns (uint256 rate); /// @notice Read rates from the circuit of both Uniswap and Chainlink if there are both circuits /// else returns twice the same price /// @return Return all available rates (Chainlink and Uniswap) with the lowest rate returned first. /// @dev The rate returned is expressed with base `BASE` (and not the base of the out-currency) function readAll() external view returns (uint256, uint256); /// @notice Reads rates from the circuit of both Uniswap and Chainlink if there are both circuits /// and returns either the highest of both rates or the lowest /// @return rate The lower rate between Chainlink and Uniswap /// @dev If there is only one rate computed in an oracle contract, then the only rate is returned /// regardless of the value of the `lower` parameter /// @dev The rate returned is expressed with base `BASE` (and not the base of the out-currency) function readLower() external view returns (uint256 rate); /// @notice Reads rates from the circuit of both Uniswap and Chainlink if there are both circuits /// and returns either the highest of both rates or the lowest /// @return rate The upper rate between Chainlink and Uniswap /// @dev If there is only one rate computed in an oracle contract, then the only rate is returned /// regardless of the value of the `lower` parameter /// @dev The rate returned is expressed with base `BASE` (and not the base of the out-currency) function readUpper() external view returns (uint256 rate); /// @notice Converts an in-currency quote amount to out-currency using one of the rates available in the oracle /// contract /// @param quoteAmount Amount (in the input collateral) to be converted to be converted in out-currency /// @return Quote amount in out-currency from the base amount in in-currency /// @dev Like in the read function, if the oracle involves a Uniswap and a Chainlink price, this function /// will use the Uniswap price to compute the out quoteAmount /// @dev The rate returned is expressed with base `BASE` (and not the base of the out-currency) function readQuote(uint256 quoteAmount) external view returns (uint256); /// @notice Returns the lowest quote amount between Uniswap and Chainlink circuits (if possible). If the oracle /// contract only involves a single feed, then this returns the value of this feed /// @param quoteAmount Amount (in the input collateral) to be converted /// @return The lowest quote amount from the quote amount in in-currency /// @dev The rate returned is expressed with base `BASE` (and not the base of the out-currency) function readQuoteLower(uint256 quoteAmount) external view returns (uint256); } /// @notice Interface for the `BondingCurve` contract /// @dev This contract allows people to buy ANGLE governance tokens using the protocol's stablecoins /// @dev It is with high certainty not going to be distributed directly at launch interface IBondingCurve { /// @notice Lets `msg.sender` buy tokens (ANGLE tokens normally) against an allowed token (a stablecoin normally) /// @param _agToken Reference to the agToken used, that is the stablecoin used to buy the token associated to this /// bonding curve /// @param maxAmountToPayInAgToken Maximum amount to pay in agTokens that the user is willing to pay to buy the /// `targetSoldTokenQuantity` function buySoldToken( IAgToken _agToken, uint256 targetSoldTokenQuantity, uint256 maxAmountToPayInAgToken ) external; /// @dev More generally than the expression used, the value of the price is: /// `startPrice/(1-tokensSoldInTx/tokensToSellInTotal)^power` with `power = 2` /// @dev The precision of this function is not that important as it is a view function anyone can query /// @notice Returns the current price of the token (expressed in reference) function getCurrentPrice() external view returns (uint256); /// @return The quantity of governance tokens that are still to be sold function getQuantityLeftToSell() external view returns (uint256); /// @param targetQuantity Quantity of ANGLE tokens to buy /// @dev This is an utility function that can be queried before buying tokens /// @return The amount to pay for the desired amount of ANGLE to buy function computePriceFromQuantity(uint256 targetQuantity) external view returns (uint256); } /// @title ICollateralSettler /// @notice Interface for the collateral settlement contracts that are used when a collateral is getting revoked interface ICollateralSettler { /// @notice Allows a user to claim collateral for a `dest` address by sending agTokens and gov tokens (optional) /// @param dest Address of the user to claim collateral for /// @param amountAgToken Amount of agTokens sent /// @param amountGovToken Amount of governance sent /// @dev The more gov tokens a user sends, the more preferably it ends up being treated during the redeem period function claimUser( address dest, uint256 amountAgToken, uint256 amountGovToken ) external; /// @notice Allows a HA to claim collateral by sending a `perpetualID` and gov tokens (optional) /// @param perpetualID Perpetual owned by the HA /// @param amountGovToken Amount of governance sent /// @dev The contract automatically recognizes the beneficiary of the perpetual function claimHA(uint256 perpetualID, uint256 amountGovToken) external; /// @notice Allows a SLP to claim collateral for an address `dest` by sending sanTokens and gov tokens (optional) /// @param dest Address to claim collateral for /// @param amountSanToken Amount of sanTokens sent /// @param amountGovToken Amount of governance tokens sent function claimSLP( address dest, uint256 amountSanToken, uint256 amountGovToken ) external; /// @notice Computes the base amount each category of claim will get after the claim period has ended /// @dev This function can only be called once when claim period is over /// @dev It is at the level of this function that the waterfall between the different /// categories of stakeholders and of claims is executed function setAmountToRedistributeEach() external; /// @notice Lets a user or a LP redeem its corresponding share of collateral /// @param user Address of the user to redeem collateral to /// @dev This function can only be called after the `setAmountToRedistributeEach` function has been called /// @dev The entry point to redeem is the same for users, HAs and SLPs function redeemCollateral(address user) external; } // SPDX-License-Identifier: MIT pragma solidity 0.8.2; interface IMultiRewards { function balanceOf(address) external returns(uint); function stakeFor(address, uint) external; function withdrawFor(address, uint) external; function notifyRewardAmount(address, uint) external; } // 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)); } }
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c8063921d983d1161010f578063b6b55f25116100a2578063de5f626811610071578063de5f62681461055e578063e5e93cff14610568578063f77c479114610572578063fc0c546a14610590576101e5565b8063b6b55f25146104ea578063d389800f14610506578063dc4c90d314610510578063dd62ed3e1461052e576101e5565b8063a6f19c84116100de578063a6f19c8414610462578063a9059cbb14610480578063ab033ea9146104b0578063b69ef8a8146104cc576101e5565b8063921d983d146103da57806392eefe9b146103f857806395d89b4114610414578063a457c2d714610432576101e5565b806339509351116101875780636ac5dc46116101565780636ac5dc461461036457806370a082311461038257806377c7b8fc146103b2578063853828b6146103d0576101e5565b806339509351146102dc5780634cf088d91461030c57806355a68ed31461032a5780635aa6e67514610346576101e5565b806318160ddd116101c357806318160ddd1461025457806323b872dd146102725780632e1a7d4d146102a2578063313ce567146102be576101e5565b8063018ee9b7146101ea57806306fdde0314610206578063095ea7b314610224575b600080fd5b61020460048036038101906101ff9190612c87565b6105ae565b005b61020e610720565b60405161021b9190613140565b60405180910390f35b61023e60048036038101906102399190612c87565b6107b2565b60405161024b919061310a565b60405180910390f35b61025c6107d0565b60405161026991906133a2565b60405180910390f35b61028c60048036038101906102879190612c38565b6107da565b604051610299919061310a565b60405180910390f35b6102bc60048036038101906102b79190612cec565b6108d2565b005b6102c6610d84565b6040516102d39190613402565b60405180910390f35b6102f660048036038101906102f19190612c87565b610d8d565b604051610303919061310a565b60405180910390f35b610314610e39565b604051610321919061308f565b60405180910390f35b610344600480360381019061033f9190612baa565b610e5f565b005b61034e610f33565b60405161035b919061308f565b60405180910390f35b61036c610f59565b604051610379919061308f565b60405180910390f35b61039c60048036038101906103979190612baa565b610f7f565b6040516103a991906133a2565b60405180910390f35b6103ba610fc7565b6040516103c791906133a2565b60405180910390f35b6103d8610fd2565b005b6103e2610fe5565b6040516103ef919061308f565b60405180910390f35b610412600480360381019061040d9190612baa565b61100b565b005b61041c6110df565b6040516104299190613140565b60405180910390f35b61044c60048036038101906104479190612c87565b611171565b604051610459919061310a565b60405180910390f35b61046a61125c565b604051610477919061308f565b60405180910390f35b61049a60048036038101906104959190612c87565b611282565b6040516104a7919061310a565b60405180910390f35b6104ca60048036038101906104c59190612baa565b6112a0565b005b6104d4611374565b6040516104e191906133a2565b60405180910390f35b61050460048036038101906104ff9190612cec565b611448565b005b61050e611682565b005b610518611943565b604051610525919061308f565b60405180910390f35b61054860048036038101906105439190612bfc565b611969565b60405161055591906133a2565b60405180910390f35b6105666119f0565b005b610570611aa5565b005b61057a611ca2565b604051610587919061308f565b60405180910390f35b610598611cc8565b6040516105a59190613125565b60405180910390f35b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610635906131e2565b60405180910390fd5b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156106cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106c690613262565b60405180910390fd5b61071c600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828473ffffffffffffffffffffffffffffffffffffffff16611cee9092919063ffffffff16565b5050565b60606003805461072f906135a9565b80601f016020809104026020016040519081016040528092919081815260200182805461075b906135a9565b80156107a85780601f1061077d576101008083540402835291602001916107a8565b820191906000526020600020905b81548152906001019060200180831161078b57829003601f168201915b5050505050905090565b60006107c66107bf611d74565b8484611d7c565b6001905092915050565b6000600254905090565b60006107e7848484611f47565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610832611d74565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156108b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a990613242565b60405180910390fd5b6108c6856108be611d74565b858403611d7c565b60019150509392505050565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b815260040161092f919061308f565b602060405180830381600087803b15801561094957600080fd5b505af115801561095d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109819190612d15565b9050808211156109c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109bd90613342565b60405180910390fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663db518db233846040518363ffffffff1660e01b8152600401610a239291906130e1565b600060405180830381600087803b158015610a3d57600080fd5b505af1158015610a51573d6000803e3d6000fd5b50505050610a5f30836121c8565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610abc919061308f565b60206040518083038186803b158015610ad457600080fd5b505afa158015610ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0c9190612d15565b905080831115610bcc57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f3fef3a3600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518363ffffffff1660e01b8152600401610b959291906130e1565b600060405180830381600087803b158015610baf57600080fd5b505af1158015610bc3573d6000803e3d6000fd5b50505050610c82565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323e103a8843030600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518563ffffffff1660e01b8152600401610c4f94939291906133bd565b600060405180830381600087803b158015610c6957600080fd5b505af1158015610c7d573d6000803e3d6000fd5b505050505b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610cdf919061308f565b60206040518083038186803b158015610cf757600080fd5b505afa158015610d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2f9190612d15565b9050610d7e3382600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611cee9092919063ffffffff16565b50505050565b60006006905090565b6000610e2f610d9a611d74565b848460016000610da8611d74565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e2a919061344f565b611d7c565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee6906131a2565b60405180910390fd5b80600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000620f4240905090565b610fe3610fde33610f7f565b6108d2565b565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461109b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611092906131a2565b60405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6060600480546110ee906135a9565b80601f016020809104026020016040519081016040528092919081815260200182805461111a906135a9565b80156111675780601f1061113c57610100808354040283529160200191611167565b820191906000526020600020905b81548152906001019060200180831161114a57829003601f168201915b5050505050905090565b60008060016000611180611d74565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561123d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123490613362565b60405180910390fd5b611251611248611d74565b85858403611d7c565b600191505092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061129661128f611d74565b8484611f47565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611330576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611327906131a2565b60405180910390fd5b80600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b81526004016113f3919061308f565b60206040518083038186803b15801561140b57600080fd5b505afa15801561141f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114439190612d15565b905090565b600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156114da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d190613282565b60405180910390fd5b611529333083600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661239f909392919063ffffffff16565b6000611533612428565b905061153f308261276a565b3073ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b815260040161159c9291906130e1565b602060405180830381600087803b1580156115b657600080fd5b505af11580156115ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ee9190612cc3565b50600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632ee4090833836040518363ffffffff1660e01b815260040161164c9291906130e1565b600060405180830381600087803b15801561166657600080fd5b505af115801561167a573d6000803e3d6000fd5b505050505050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611712576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611709906131a2565b60405180910390fd5b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166339ebf823600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401611791919061308f565b60206040518083038186803b1580156117a957600080fd5b505afa1580156117bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e19190612bd3565b90506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611840919061308f565b60206040518083038186803b15801561185857600080fd5b505afa15801561186c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118909190612d15565b90506118df8282600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611cee9092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff16633a4b66f16040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561192757600080fd5b505af115801561193b573d6000803e3d6000fd5b505050505050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611aa3600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401611a4e919061308f565b60206040518083038186803b158015611a6657600080fd5b505afa158015611a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9e9190612d15565b611448565b565b6000600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401611b02919061308f565b602060405180830381600087803b158015611b1c57600080fd5b505af1158015611b30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b549190612d15565b9050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663db518db233836040518363ffffffff1660e01b8152600401611bb39291906130e1565b600060405180830381600087803b158015611bcd57600080fd5b505af1158015611be1573d6000803e3d6000fd5b50505050611bef30826121c8565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401611c4c9291906130e1565b602060405180830381600087803b158015611c6657600080fd5b505af1158015611c7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9e9190612cc3565b5050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611d6f8363a9059cbb60e01b8484604051602401611d0d9291906130e1565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506128ca565b505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611de3906132e2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e53906131c2565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611f3a91906133a2565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611fb7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fae906132c2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612027576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161201e90613162565b60405180910390fd5b612032838383612991565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156120b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120af90613202565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461214b919061344f565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516121af91906133a2565b60405180910390a36121c2848484612996565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612238576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161222f906132a2565b60405180910390fd5b61224482600083612991565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156122ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122c190613182565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816002600082825461232191906134a5565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161238691906133a2565b60405180910390a361239a83600084612996565b505050565b612422846323b872dd60e01b8585856040516024016123c0939291906130aa565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506128ca565b50505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612486919061308f565b60206040518083038186803b15801561249e57600080fd5b505afa1580156124b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d69190612d15565b90506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612535919061308f565b60206040518083038186803b15801561254d57600080fd5b505afa158015612561573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125859190612d15565b90506125f6600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611cee9092919063ffffffff16565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b02bf4b9600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b81526004016126759291906130e1565b600060405180830381600087803b15801561268f57600080fd5b505af11580156126a3573d6000803e3d6000fd5b505050506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401612704919061308f565b60206040518083038186803b15801561271c57600080fd5b505afa158015612730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127549190612d15565b9050818161276291906134a5565b935050505090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156127da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127d190613382565b60405180910390fd5b6127e660008383612991565b80600260008282546127f8919061344f565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461284d919061344f565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516128b291906133a2565b60405180910390a36128c660008383612996565b5050565b600061292c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661299b9092919063ffffffff16565b905060008151111561298c578080602001905181019061294c9190612cc3565b61298b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161298290613322565b60405180910390fd5b5b505050565b505050565b505050565b60606129aa84846000856129b3565b90509392505050565b6060824710156129f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129ef90613222565b60405180910390fd5b612a0185612ac7565b612a40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a3790613302565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051612a699190613078565b60006040518083038185875af1925050503d8060008114612aa6576040519150601f19603f3d011682016040523d82523d6000602084013e612aab565b606091505b5091509150612abb828286612ada565b92505050949350505050565b600080823b905060008111915050919050565b60608315612aea57829050612b3a565b600083511115612afd5782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b319190613140565b60405180910390fd5b9392505050565b600081359050612b5081613ace565b92915050565b600081519050612b6581613ace565b92915050565b600081519050612b7a81613ae5565b92915050565b600081359050612b8f81613afc565b92915050565b600081519050612ba481613afc565b92915050565b600060208284031215612bbc57600080fd5b6000612bca84828501612b41565b91505092915050565b600060208284031215612be557600080fd5b6000612bf384828501612b56565b91505092915050565b60008060408385031215612c0f57600080fd5b6000612c1d85828601612b41565b9250506020612c2e85828601612b41565b9150509250929050565b600080600060608486031215612c4d57600080fd5b6000612c5b86828701612b41565b9350506020612c6c86828701612b41565b9250506040612c7d86828701612b80565b9150509250925092565b60008060408385031215612c9a57600080fd5b6000612ca885828601612b41565b9250506020612cb985828601612b80565b9150509250929050565b600060208284031215612cd557600080fd5b6000612ce384828501612b6b565b91505092915050565b600060208284031215612cfe57600080fd5b6000612d0c84828501612b80565b91505092915050565b600060208284031215612d2757600080fd5b6000612d3584828501612b95565b91505092915050565b612d47816134d9565b82525050565b612d56816134eb565b82525050565b6000612d678261341d565b612d718185613433565b9350612d81818560208601613576565b80840191505092915050565b612d968161352e565b82525050565b612da581613552565b82525050565b6000612db682613428565b612dc0818561343e565b9350612dd0818560208601613576565b612dd981613639565b840191505092915050565b6000612df160238361343e565b9150612dfc8261364a565b604082019050919050565b6000612e1460228361343e565b9150612e1f82613699565b604082019050919050565b6000612e37600b8361343e565b9150612e42826136e8565b602082019050919050565b6000612e5a60228361343e565b9150612e6582613711565b604082019050919050565b6000612e7d600b8361343e565b9150612e8882613760565b602082019050919050565b6000612ea060268361343e565b9150612eab82613789565b604082019050919050565b6000612ec360268361343e565b9150612ece826137d8565b604082019050919050565b6000612ee660288361343e565b9150612ef182613827565b604082019050919050565b6000612f0960058361343e565b9150612f1482613876565b602082019050919050565b6000612f2c60198361343e565b9150612f378261389f565b602082019050919050565b6000612f4f60218361343e565b9150612f5a826138c8565b604082019050919050565b6000612f7260258361343e565b9150612f7d82613917565b604082019050919050565b6000612f9560248361343e565b9150612fa082613966565b604082019050919050565b6000612fb8601d8361343e565b9150612fc3826139b5565b602082019050919050565b6000612fdb602a8361343e565b9150612fe6826139de565b604082019050919050565b6000612ffe60118361343e565b915061300982613a2d565b602082019050919050565b600061302160258361343e565b915061302c82613a56565b604082019050919050565b6000613044601f8361343e565b915061304f82613aa5565b602082019050919050565b61306381613517565b82525050565b61307281613521565b82525050565b60006130848284612d5c565b915081905092915050565b60006020820190506130a46000830184612d3e565b92915050565b60006060820190506130bf6000830186612d3e565b6130cc6020830185612d3e565b6130d9604083018461305a565b949350505050565b60006040820190506130f66000830185612d3e565b613103602083018461305a565b9392505050565b600060208201905061311f6000830184612d4d565b92915050565b600060208201905061313a6000830184612d8d565b92915050565b6000602082019050818103600083015261315a8184612dab565b905092915050565b6000602082019050818103600083015261317b81612de4565b9050919050565b6000602082019050818103600083015261319b81612e07565b9050919050565b600060208201905081810360008301526131bb81612e2a565b9050919050565b600060208201905081810360008301526131db81612e4d565b9050919050565b600060208201905081810360008301526131fb81612e70565b9050919050565b6000602082019050818103600083015261321b81612e93565b9050919050565b6000602082019050818103600083015261323b81612eb6565b9050919050565b6000602082019050818103600083015261325b81612ed9565b9050919050565b6000602082019050818103600083015261327b81612efc565b9050919050565b6000602082019050818103600083015261329b81612f1f565b9050919050565b600060208201905081810360008301526132bb81612f42565b9050919050565b600060208201905081810360008301526132db81612f65565b9050919050565b600060208201905081810360008301526132fb81612f88565b9050919050565b6000602082019050818103600083015261331b81612fab565b9050919050565b6000602082019050818103600083015261333b81612fce565b9050919050565b6000602082019050818103600083015261335b81612ff1565b9050919050565b6000602082019050818103600083015261337b81613014565b9050919050565b6000602082019050818103600083015261339b81613037565b9050919050565b60006020820190506133b7600083018461305a565b92915050565b60006080820190506133d2600083018761305a565b6133df6020830186612d3e565b6133ec6040830185612d3e565b6133f96060830184612d9c565b95945050505050565b60006020820190506134176000830184613069565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061345a82613517565b915061346583613517565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561349a576134996135db565b5b828201905092915050565b60006134b082613517565b91506134bb83613517565b9250828210156134ce576134cd6135db565b5b828203905092915050565b60006134e4826134f7565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061353982613540565b9050919050565b600061354b826134f7565b9050919050565b600061355d82613564565b9050919050565b600061356f826134f7565b9050919050565b60005b83811015613594578082015181840152602081019050613579565b838111156135a3576000848401525b50505050565b600060028204905060018216806135c157607f821691505b602082108114156135d5576135d461360a565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f21676f7665726e616e6365000000000000000000000000000000000000000000600082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f21636f6e74726f6c6c6572000000000000000000000000000000000000000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f746f6b656e000000000000000000000000000000000000000000000000000000600082015250565b7f4761756765206e6f742079657420696e697469616c697a656400000000000000600082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f4e6f7420656e6f756768207374616b6564000000000000000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b613ad7816134d9565b8114613ae257600080fd5b50565b613aee816134eb565b8114613af957600080fd5b50565b613b0581613517565b8114613b1057600080fd5b5056fea2646970667358221220cfc66c2154348dcf6c3a6669dac56af99419aab541e1deefd97518733584b58264736f6c63430008020033
[ 16, 5 ]
0xf3c384b9321abd6c0a6cbd1fddf97d4b125c6b81
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title S4fechainProxy * @dev This contract combines an upgradeability proxy with basic authorization control functionalities */ contract OwnedUpgradeabilityProxy { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address previousOwner, address newOwner); /** * @dev This event will be emitted every time the implementation gets upgraded * @param implementation representing the address of the upgraded implementation */ event Upgraded(address indexed implementation); // Storage position of the address of the maintenance boolean bytes32 private constant maintenancePosition = keccak256("com.s4fechain.proxy.maintenance"); // Storage position of the address of the current implementation bytes32 private constant implementationPosition = keccak256("com.s4fechain.proxy.implementation"); // Storage position of the owner of the contract bytes32 private constant proxyOwnerPosition = keccak256("com.s4fechain.proxy.owner"); /** * @dev the constructor sets the original owner of the contract to the sender account. */ constructor() { setUpgradeabilityOwner(msg.sender); } /** * @dev Tells if contract is on maintenance * @return _maintenance if contract is on maintenance */ function maintenance() public view returns (bool _maintenance) { bytes32 position = maintenancePosition; assembly { _maintenance := sload(position) } } /** * @dev Sets if contract is on maintenance */ function setMaintenance(bool _maintenance) external onlyProxyOwner { bytes32 position = maintenancePosition; assembly { sstore(position, _maintenance) } } /** * @dev Tells the address of the owner * @return owner the address of the owner */ function proxyOwner() public view returns (address owner) { bytes32 position = proxyOwnerPosition; assembly { owner := sload(position) } } /** * @dev Sets the address of the owner */ function setUpgradeabilityOwner(address newProxyOwner) internal { bytes32 position = proxyOwnerPosition; assembly { sstore(position, newProxyOwner) } } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferProxyOwnership(address newOwner) public onlyProxyOwner { require(newOwner != address(0), 'OwnedUpgradeabilityProxy: INVALID'); emit ProxyOwnershipTransferred(proxyOwner(), newOwner); setUpgradeabilityOwner(newOwner); } /** * @dev Allows the proxy owner to upgrade the current version of the proxy. * @param _implementation representing the address of the new implementation to be set. */ function upgradeTo(address _implementation) public onlyProxyOwner { _upgradeTo(_implementation); } /** * @dev Allows the proxy owner to upgrade the current version of the proxy and call the new implementation * to initialize whatever is needed through a low level call. * @param _implementation representing the address of the new implementation to be set. * @param data represents the msg.data to bet sent in the low level call. This parameter may include the function * signature of the implementation to be called with the needed payload */ function upgradeToAndCall(address _implementation, bytes memory data) payable public onlyProxyOwner { upgradeTo(_implementation); (bool success, ) = address(this).call{ value: msg.value }(data); require(success, "OwnedUpgradeabilityProxy: INVALID"); } /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ fallback() external payable { _fallback(); } receive () external payable { _fallback(); } /** * @dev Tells the address of the current implementation * @return impl address of the current implementation */ function implementation() public view returns (address impl) { bytes32 position = implementationPosition; assembly { impl := sload(position) } } /** * @dev Sets the address of the current implementation * @param newImplementation address representing the new implementation to be set */ function setImplementation(address newImplementation) internal { bytes32 position = implementationPosition; assembly { sstore(position, newImplementation) } } /** * @dev Upgrades the implementation address * @param newImplementation representing the address of the new implementation to be set */ function _upgradeTo(address newImplementation) internal { address currentImplementation = implementation(); require(currentImplementation != newImplementation, 'OwnedUpgradeabilityProxy: INVALID'); setImplementation(newImplementation); emit Upgraded(newImplementation); } function _fallback() internal { if (maintenance()) { require(msg.sender == proxyOwner(), 'OwnedUpgradeabilityProxy: FORBIDDEN'); } address _impl = implementation(); require(_impl != address(0), 'OwnedUpgradeabilityProxy: INVALID'); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner(), 'OwnedUpgradeabilityProxy: FORBIDDEN'); _; } }
0x6080604052600436106100745760003560e01c80635c60da1b1161004e5780635c60da1b146100f9578063612f2f371461011b5780636c376cc51461013b578063f1739cae1461017a57610083565b8063025313a21461008b5780633659cfe6146100c65780634f1ef286146100e657610083565b366100835761008161019a565b005b61008161019a565b34801561009757600080fd5b50600080516020610748833981519152545b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100d257600080fd5b506100816100e1366004610576565b61026f565b6100816100f4366004610597565b6102bb565b34801561010557600080fd5b50600080516020610768833981519152546100a9565b34801561012757600080fd5b50610081610136366004610654565b610387565b34801561014757600080fd5b507f9d985125a5ee409336bdf8c4ad76e5480c78722540dd5a291e09a0e688ceb6335460405190151581526020016100bd565b34801561018657600080fd5b50610081610195366004610576565b6103eb565b7f9d985125a5ee409336bdf8c4ad76e5480c78722540dd5a291e09a0e688ceb633541561020a57600080516020610748833981519152546001600160a01b0316336001600160a01b03161461020a5760405162461bcd60e51b8152600401610201906106ee565b60405180910390fd5b60006102226000805160206107688339815191525490565b90506001600160a01b03811661024a5760405162461bcd60e51b8152600401610201906106ad565b60405136600082376000803683855af43d806000843e81801561026b578184f35b8184fd5b600080516020610748833981519152546001600160a01b0316336001600160a01b0316146102af5760405162461bcd60e51b8152600401610201906106ee565b6102b8816104c0565b50565b600080516020610748833981519152546001600160a01b0316336001600160a01b0316146102fb5760405162461bcd60e51b8152600401610201906106ee565b6103048261026f565b6000306001600160a01b0316348360405161031f9190610674565b60006040518083038185875af1925050503d806000811461035c576040519150601f19603f3d011682016040523d82523d6000602084013e610361565b606091505b50509050806103825760405162461bcd60e51b8152600401610201906106ad565b505050565b600080516020610748833981519152546001600160a01b0316336001600160a01b0316146103c75760405162461bcd60e51b8152600401610201906106ee565b7f9d985125a5ee409336bdf8c4ad76e5480c78722540dd5a291e09a0e688ceb63355565b600080516020610748833981519152546001600160a01b0316336001600160a01b03161461042b5760405162461bcd60e51b8152600401610201906106ee565b6001600160a01b0381166104515760405162461bcd60e51b8152600401610201906106ad565b7f5a3e66efaa1e445ebd894728a69d6959842ea1e97bd79b892797106e270efcd96104886000805160206107488339815191525490565b604080516001600160a01b03928316815291841660208301520160405180910390a16102b88160008051602061074883398151915255565b60006104d86000805160206107688339815191525490565b9050816001600160a01b0316816001600160a01b0316141561050c5760405162461bcd60e51b8152600401610201906106ad565b6105228260008051602061076883398151915255565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a25050565b80356001600160a01b038116811461057157600080fd5b919050565b600060208284031215610587578081fd5b6105908261055a565b9392505050565b600080604083850312156105a9578081fd5b6105b28361055a565b9150602083013567ffffffffffffffff808211156105ce578283fd5b818501915085601f8301126105e1578283fd5b8135818111156105f3576105f3610731565b604051601f8201601f19908116603f0116810190838211818310171561061b5761061b610731565b81604052828152886020848701011115610633578586fd5b82602086016020830137856020848301015280955050505050509250929050565b600060208284031215610665578081fd5b81358015158114610590578182fd5b60008251815b81811015610694576020818601810151858301520161067a565b818111156106a25782828501525b509190910192915050565b60208082526021908201527f4f776e6564557067726164656162696c69747950726f78793a20494e56414c496040820152601160fa1b606082015260800190565b60208082526023908201527f4f776e6564557067726164656162696c69747950726f78793a20464f524249446040820152622222a760e91b606082015260800190565b634e487b7160e01b600052604160045260246000fdfe05bd85affbe38b6e7a2667fd562b199e26e42eed0c29bd9a73a2442209a6807dcb8459713ae860ab95accf1e2a5576c9db5614a52cf76df7e66ad0a7bbe09940a2646970667358221220bda69316b6cb44e70247568c25434b8dd75deaa96ef58b623ec243d3036f534764736f6c63430008040033
[ 38 ]
0xf3c3a688e3fb809202754db83bf17a7487d718f0
// File: @chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol // 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 ); } // File: @openzeppelin/contracts/utils/Context.sol // 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; } } // File: @openzeppelin/contracts/access/Ownable.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/BloctoPointExchange.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.6; contract BloctoPointExchange is Ownable { event Buy(address buyer, address receiver, uint tokenAmount, uint point); AggregatorV3Interface internal usdPriceFeed; uint internal usdPricePerPoint = 1 * 10**5; // default 0.001 usd address payable tokenReceiver; constructor(address _owner, address _usdPriceFeed, address payable _tokenReceiver) public { transferOwnership(_owner); usdPriceFeed = AggregatorV3Interface(_usdPriceFeed); tokenReceiver = _tokenReceiver; } /** * Returns the latest usd price */ function getUSDPrice() public view returns (int) { ( /* uint80 roundID */, int price, /* uint startedAt */, /* uint timeStamp */, /* uint80 answeredInRound */ ) = usdPriceFeed.latestRoundData(); return price; } function estimateTokenAmount(uint points) public view returns (uint) { return points * usdPricePerPoint * 10**18 / uint(getUSDPrice()); } function estimateBP(uint _amount) public view returns (uint) { return _amount * uint(getUSDPrice()) / usdPricePerPoint / 10**18; } function buyBP() external payable { uint points = estimateBP(msg.value); tokenReceiver.transfer(msg.value); emit Buy(msg.sender, msg.sender, msg.value, points); } }
0x6080604052600436106100705760003560e01c80637cbbde7c1161004e5780637cbbde7c146100d05780638da5cb5b146100fa578063c338287f1461012b578063f2fde38b1461014057610070565b80631b05ab791461007557806344340188146100b1578063715018a6146100bb575b600080fd5b34801561008157600080fd5b5061009f6004803603602081101561009857600080fd5b5035610173565b60408051918252519081900360200190f35b6100b961019a565b005b3480156100c757600080fd5b506100b9610228565b3480156100dc57600080fd5b5061009f600480360360208110156100f357600080fd5b50356102e6565b34801561010657600080fd5b5061010f61030d565b604080516001600160a01b039092168252519081900360200190f35b34801561013757600080fd5b5061009f61031c565b34801561014c57600080fd5b506100b96004803603602081101561016357600080fd5b50356001600160a01b03166103a2565b600061017d61031c565b6002548302670de0b6b3a7640000028161019357fe5b0492915050565b60006101a5346102e6565b6003546040519192506001600160a01b0316903480156108fc02916000818181858888f193505050501580156101df573d6000803e3d6000fd5b506040805133808252602082015234818301526060810183905290517f89f5adc174562e07c9c9b1cae7109bbecb21cf9d1b2847e550042b8653c54a0e9181900360800190a150565b6102306104b6565b6001600160a01b031661024161030d565b6001600160a01b03161461029c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000670de0b6b3a76400006002546102fc61031c565b84028161030557fe5b048161019357fe5b6000546001600160a01b031690565b600080600160009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b15801561036d57600080fd5b505afa158015610381573d6000803e3d6000fd5b505050506040513d60a081101561039757600080fd5b506020015191505090565b6103aa6104b6565b6001600160a01b03166103bb61030d565b6001600160a01b031614610416576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661045b5760405162461bcd60e51b81526004018080602001828103825260268152602001806104bb6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220ed15d66af15c6cc0fcdff718b9166418951f166444208fab5e33c979b72eca7764736f6c63430006060033
[ 38 ]
0xF3C422bbd5935CC37a7A2542f81940144300c0a6
// SPDX-License-Identifier: MIT // 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/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/ChubbyCherubs.sol pragma solidity 0.8.11; contract ChubbyCherubs is ERC721, Ownable { uint256 private mintCount = 0; uint256 public constant MAX_CHUB = 1111; uint256 public price = 70000000000000000; //0.07 Ether string baseTokenURI; bool public saleOpen; event ChubMinted(uint256 totalMinted); constructor(string memory baseURI) ERC721("Chubby Cherubs", "CHUB") { setBaseURI(baseURI); } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function totalSupply() public view returns (uint256) { return mintCount; } function setPrice(uint256 _newPrice) external onlyOwner { price = _newPrice; } //Close sale if open, open sale if closed function flipSaleState() external onlyOwner { saleOpen = !saleOpen; } function withdrawAll() external onlyOwner { (bool success, ) = msg.sender.call{value: address(this).balance}(""); require(success, "Transfer failed."); } function airdrop(address[] calldata _recipients) external onlyOwner { uint256 supply = totalSupply(); require( supply + _recipients.length <= MAX_CHUB, "Airdrop will exceed maximum supply of CHUB" ); require(_recipients.length != 0, "Address not found"); mintCount += _recipients.length; for (uint256 i = 0; i < _recipients.length; i++) { require(_recipients[i] != address(0), "Airdrop to Null address"); handleMint(_recipients[i], ++supply); } } //mint CHUB function mint(uint256 _count) external payable { uint256 supply = totalSupply(); require(supply + _count <= MAX_CHUB, "Exceeds maximum supply of CHUB"); require(_count > 0, "Minimum 1 CHUB has to be minted per transaction"); if (msg.sender != owner()) { require(saleOpen, "Sale is not open yet"); require( _count <= 10, "Maximum 10 Chubby Cherubs can be minted per transaction" ); require( msg.value >= price * _count, "Ether sent with this transaction is not correct" ); } mintCount += _count; for (uint256 i = 0; i < _count; i++) { handleMint(msg.sender, ++supply); } } function handleMint(address _to, uint256 tokenId) private { _safeMint(_to, tokenId); emit ChubMinted(tokenId); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } }
0x6080604052600436106101815760003560e01c8063729ad39e116100d1578063a035b1fe1161008a578063b88d4fde11610064578063b88d4fde14610421578063c87b56dd14610441578063e985e9c514610461578063f2fde38b146104aa57600080fd5b8063a035b1fe146103d8578063a0712d68146103ee578063a22cb4651461040157600080fd5b8063729ad39e14610336578063853828b6146103565780638da5cb5b1461036b57806391b7f5ed1461038957806395d89b41146103a957806399288dbb146103be57600080fd5b806334918dfd1161013e57806355f804b31161011857806355f804b3146102c15780636352211e146102e157806370a0823114610301578063715018a61461032157600080fd5b806334918dfd1461027657806342842e0e1461028b578063530b4ade146102ab57600080fd5b806301ffc9a71461018657806306fdde03146101bb578063081812fc146101dd578063095ea7b31461021557806318160ddd1461023757806323b872dd14610256575b600080fd5b34801561019257600080fd5b506101a66101a136600461191e565b6104ca565b60405190151581526020015b60405180910390f35b3480156101c757600080fd5b506101d061051c565b6040516101b29190611993565b3480156101e957600080fd5b506101fd6101f83660046119a6565b6105ae565b6040516001600160a01b0390911681526020016101b2565b34801561022157600080fd5b506102356102303660046119db565b610648565b005b34801561024357600080fd5b506007545b6040519081526020016101b2565b34801561026257600080fd5b50610235610271366004611a05565b61075e565b34801561028257600080fd5b5061023561078f565b34801561029757600080fd5b506102356102a6366004611a05565b6107cd565b3480156102b757600080fd5b5061024861045781565b3480156102cd57600080fd5b506102356102dc366004611acd565b6107e8565b3480156102ed57600080fd5b506101fd6102fc3660046119a6565b610829565b34801561030d57600080fd5b5061024861031c366004611b16565b6108a0565b34801561032d57600080fd5b50610235610927565b34801561034257600080fd5b50610235610351366004611b31565b61095d565b34801561036257600080fd5b50610235610b3c565b34801561037757600080fd5b506006546001600160a01b03166101fd565b34801561039557600080fd5b506102356103a43660046119a6565b610bf4565b3480156103b557600080fd5b506101d0610c23565b3480156103ca57600080fd5b50600a546101a69060ff1681565b3480156103e457600080fd5b5061024860085481565b6102356103fc3660046119a6565b610c32565b34801561040d57600080fd5b5061023561041c366004611ba6565b610e8b565b34801561042d57600080fd5b5061023561043c366004611be2565b610e96565b34801561044d57600080fd5b506101d061045c3660046119a6565b610ec8565b34801561046d57600080fd5b506101a661047c366004611c5e565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156104b657600080fd5b506102356104c5366004611b16565b610fa3565b60006001600160e01b031982166380ac58cd60e01b14806104fb57506001600160e01b03198216635b5e139f60e01b145b8061051657506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461052b90611c91565b80601f016020809104026020016040519081016040528092919081815260200182805461055790611c91565b80156105a45780601f10610579576101008083540402835291602001916105a4565b820191906000526020600020905b81548152906001019060200180831161058757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661062c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061065382610829565b9050806001600160a01b0316836001600160a01b031614156106c15760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610623565b336001600160a01b03821614806106dd57506106dd813361047c565b61074f5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610623565b610759838361103b565b505050565b61076833826110a9565b6107845760405162461bcd60e51b815260040161062390611ccc565b6107598383836111a0565b6006546001600160a01b031633146107b95760405162461bcd60e51b815260040161062390611d1d565b600a805460ff19811660ff90911615179055565b61075983838360405180602001604052806000815250610e96565b6006546001600160a01b031633146108125760405162461bcd60e51b815260040161062390611d1d565b805161082590600990602084019061186f565b5050565b6000818152600260205260408120546001600160a01b0316806105165760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610623565b60006001600160a01b03821661090b5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610623565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146109515760405162461bcd60e51b815260040161062390611d1d565b61095b6000611340565b565b6006546001600160a01b031633146109875760405162461bcd60e51b815260040161062390611d1d565b600061099260075490565b90506104576109a18383611d68565b1115610a025760405162461bcd60e51b815260206004820152602a60248201527f41697264726f702077696c6c20657863656564206d6178696d756d2073757070604482015269363c9037b31021a42aa160b11b6064820152608401610623565b81610a435760405162461bcd60e51b81526020600482015260116024820152701059191c995cdcc81b9bdd08199bdd5b99607a1b6044820152606401610623565b8282905060076000828254610a589190611d68565b90915550600090505b82811015610b36576000848483818110610a7d57610a7d611d80565b9050602002016020810190610a929190611b16565b6001600160a01b03161415610ae95760405162461bcd60e51b815260206004820152601760248201527f41697264726f7020746f204e756c6c20616464726573730000000000000000006044820152606401610623565b610b24848483818110610afe57610afe611d80565b9050602002016020810190610b139190611b16565b610b1c84611d96565b935083611392565b80610b2e81611d96565b915050610a61565b50505050565b6006546001600160a01b03163314610b665760405162461bcd60e51b815260040161062390611d1d565b604051600090339047908381818185875af1925050503d8060008114610ba8576040519150601f19603f3d011682016040523d82523d6000602084013e610bad565b606091505b5050905080610bf15760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b6044820152606401610623565b50565b6006546001600160a01b03163314610c1e5760405162461bcd60e51b815260040161062390611d1d565b600855565b60606001805461052b90611c91565b6000610c3d60075490565b9050610457610c4c8383611d68565b1115610c9a5760405162461bcd60e51b815260206004820152601e60248201527f45786365656473206d6178696d756d20737570706c79206f66204348554200006044820152606401610623565b60008211610d025760405162461bcd60e51b815260206004820152602f60248201527f4d696e696d756d203120434855422068617320746f206265206d696e7465642060448201526e3832b9103a3930b739b0b1ba34b7b760891b6064820152608401610623565b6006546001600160a01b03163314610e4957600a5460ff16610d5d5760405162461bcd60e51b815260206004820152601460248201527314d85b19481a5cc81b9bdd081bdc195b881e595d60621b6044820152606401610623565b600a821115610dd45760405162461bcd60e51b815260206004820152603760248201527f4d6178696d756d2031302043687562627920436865727562732063616e20626560448201527f206d696e74656420706572207472616e73616374696f6e0000000000000000006064820152608401610623565b81600854610de29190611db1565b341015610e495760405162461bcd60e51b815260206004820152602f60248201527f45746865722073656e7420776974682074686973207472616e73616374696f6e60448201526e081a5cc81b9bdd0818dbdc9c9958dd608a1b6064820152608401610623565b8160076000828254610e5b9190611d68565b90915550600090505b8281101561075957610e7933610b1c84611d96565b80610e8381611d96565b915050610e64565b6108253383836113d3565b610ea033836110a9565b610ebc5760405162461bcd60e51b815260040161062390611ccc565b610b36848484846114a2565b6000818152600260205260409020546060906001600160a01b0316610f475760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610623565b6000610f516114d5565b90506000815111610f715760405180602001604052806000815250610f9c565b80610f7b846114e4565b604051602001610f8c929190611dd0565b6040516020818303038152906040525b9392505050565b6006546001600160a01b03163314610fcd5760405162461bcd60e51b815260040161062390611d1d565b6001600160a01b0381166110325760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610623565b610bf181611340565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061107082610829565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166111225760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610623565b600061112d83610829565b9050806001600160a01b0316846001600160a01b031614806111685750836001600160a01b031661115d846105ae565b6001600160a01b0316145b8061119857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166111b382610829565b6001600160a01b03161461121b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610623565b6001600160a01b03821661127d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610623565b61128860008261103b565b6001600160a01b03831660009081526003602052604081208054600192906112b1908490611dff565b90915550506001600160a01b03821660009081526003602052604081208054600192906112df908490611d68565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61139c82826115e2565b6040518181527f28dce6e49d22b99d2df61fbc59c761697dc8ed0e33cd41ad36e7525cb3110ae29060200160405180910390a15050565b816001600160a01b0316836001600160a01b031614156114355760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610623565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6114ad8484846111a0565b6114b9848484846115fc565b610b365760405162461bcd60e51b815260040161062390611e16565b60606009805461052b90611c91565b6060816115085750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611532578061151c81611d96565b915061152b9050600a83611e7e565b915061150c565b60008167ffffffffffffffff81111561154d5761154d611a41565b6040519080825280601f01601f191660200182016040528015611577576020820181803683370190505b5090505b84156111985761158c600183611dff565b9150611599600a86611e92565b6115a4906030611d68565b60f81b8183815181106115b9576115b9611d80565b60200101906001600160f81b031916908160001a9053506115db600a86611e7e565b945061157b565b6108258282604051806020016040528060008152506116fa565b60006001600160a01b0384163b156116ef57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611640903390899088908890600401611ea6565b6020604051808303816000875af192505050801561167b575060408051601f3d908101601f1916820190925261167891810190611ee3565b60015b6116d5573d8080156116a9576040519150601f19603f3d011682016040523d82523d6000602084013e6116ae565b606091505b5080516116cd5760405162461bcd60e51b815260040161062390611e16565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611198565b506001949350505050565b611704838361172d565b61171160008484846115fc565b6107595760405162461bcd60e51b815260040161062390611e16565b6001600160a01b0382166117835760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610623565b6000818152600260205260409020546001600160a01b0316156117e85760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610623565b6001600160a01b0382166000908152600360205260408120805460019290611811908490611d68565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461187b90611c91565b90600052602060002090601f01602090048101928261189d57600085556118e3565b82601f106118b657805160ff19168380011785556118e3565b828001600101855582156118e3579182015b828111156118e35782518255916020019190600101906118c8565b506118ef9291506118f3565b5090565b5b808211156118ef57600081556001016118f4565b6001600160e01b031981168114610bf157600080fd5b60006020828403121561193057600080fd5b8135610f9c81611908565b60005b8381101561195657818101518382015260200161193e565b83811115610b365750506000910152565b6000815180845261197f81602086016020860161193b565b601f01601f19169290920160200192915050565b602081526000610f9c6020830184611967565b6000602082840312156119b857600080fd5b5035919050565b80356001600160a01b03811681146119d657600080fd5b919050565b600080604083850312156119ee57600080fd5b6119f7836119bf565b946020939093013593505050565b600080600060608486031215611a1a57600080fd5b611a23846119bf565b9250611a31602085016119bf565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115611a7257611a72611a41565b604051601f8501601f19908116603f01168101908282118183101715611a9a57611a9a611a41565b81604052809350858152868686011115611ab357600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215611adf57600080fd5b813567ffffffffffffffff811115611af657600080fd5b8201601f81018413611b0757600080fd5b61119884823560208401611a57565b600060208284031215611b2857600080fd5b610f9c826119bf565b60008060208385031215611b4457600080fd5b823567ffffffffffffffff80821115611b5c57600080fd5b818501915085601f830112611b7057600080fd5b813581811115611b7f57600080fd5b8660208260051b8501011115611b9457600080fd5b60209290920196919550909350505050565b60008060408385031215611bb957600080fd5b611bc2836119bf565b915060208301358015158114611bd757600080fd5b809150509250929050565b60008060008060808587031215611bf857600080fd5b611c01856119bf565b9350611c0f602086016119bf565b925060408501359150606085013567ffffffffffffffff811115611c3257600080fd5b8501601f81018713611c4357600080fd5b611c5287823560208401611a57565b91505092959194509250565b60008060408385031215611c7157600080fd5b611c7a836119bf565b9150611c88602084016119bf565b90509250929050565b600181811c90821680611ca557607f821691505b60208210811415611cc657634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008219821115611d7b57611d7b611d52565b500190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415611daa57611daa611d52565b5060010190565b6000816000190483118215151615611dcb57611dcb611d52565b500290565b60008351611de281846020880161193b565b835190830190611df681836020880161193b565b01949350505050565b600082821015611e1157611e11611d52565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b600082611e8d57611e8d611e68565b500490565b600082611ea157611ea1611e68565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611ed990830184611967565b9695505050505050565b600060208284031215611ef557600080fd5b8151610f9c8161190856fea2646970667358221220b6ba27d31207b4a830e3e28693f327dfc2361344462fe4079b6d561a3f1de3af64736f6c634300080b0033
[ 5 ]
0xf3c4f55d027e635a9092af89fed3da6184083f18
/** *Submitted for verification at Etherscan.io on 2020-09-02 */ /* * @dev This is the Axia Protocol Staking pool 3 contract (SWAP Pool), * a part of the protocol where stakers are rewarded in AXIA tokens * when they make stakes of liquidity tokens from the oracle pool. * stakers reward come from the daily emission from the total supply into circulation, * this happens daily and upon the reach of a new epoch each made of 180 days, * halvings are experienced on the emitting amount of tokens. * on the 11th epoch all the tokens would have been completed emitted into circulation, * from here on, the stakers will still be earning from daily emissions * which would now be coming from the accumulated basis points over the epochs. * stakers are not charged any fee for unstaking. */ pragma solidity 0.6.4; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } 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 USP{ using SafeMath for uint256; //======================================EVENTS=========================================// event StakeEvent(address indexed staker, address indexed pool, uint amount); event UnstakeEvent(address indexed unstaker, address indexed pool, uint amount); event RewardEvent(address indexed staker, address indexed pool, uint amount); event RewardStake(address indexed staker, address indexed pool, uint amount); //======================================STAKING POOLS=========================================// address public Axiatoken; address public UniswapV2; bool public stakingEnabled; uint256 constant private FLOAT_SCALAR = 2**64; uint256 public MINIMUM_STAKE = 1000000000000000000; // 1 minimum uint256 public MIN_DIVIDENDS_DUR = 18 hours; uint public infocheck; struct User { uint256 balance; uint256 frozen; int256 scaledPayout; uint256 staketime; } struct Info { uint256 totalSupply; uint256 totalFrozen; mapping(address => User) users; uint256 scaledPayoutPerToken; //pool balance address admin; } Info private info; constructor() public { info.admin = msg.sender; stakingEnabled = false; } //======================================ADMINSTRATION=========================================// modifier onlyCreator() { require(msg.sender == info.admin, "Ownable: caller is not the administrator"); _; } modifier onlyAxiaToken() { require(msg.sender == Axiatoken, "Authorization: only token contract can call"); _; } function tokenconfigs(address _axiatoken, address _univ2) public onlyCreator returns (bool success) { require(_axiatoken != _univ2, "Insertion of same address is not supported"); require(_axiatoken != address(0) && _univ2 != address(0), "Insertion of address(0) is not supported"); Axiatoken = _axiatoken; UniswapV2 = _univ2; return true; } function _minStakeAmount(uint256 _number) onlyCreator public { MINIMUM_STAKE = _number*1000000000000000000; } function stakingStatus(bool _status) public onlyCreator { require(Axiatoken != address(0) && UniswapV2 != address(0), "Pool addresses are not yet setup"); stakingEnabled = _status; } function MIN_DIVIDENDS_DUR_TIME(uint256 _minDuration) public onlyCreator { MIN_DIVIDENDS_DUR = _minDuration; } //======================================USER WRITE=========================================// function StakeAxiaTokens(uint256 _tokens) external { _stake(_tokens); } function UnstakeAxiaTokens(uint256 _tokens) external { _unstake(_tokens); } //======================================USER READ=========================================// function totalFrozen() public view returns (uint256) { return info.totalFrozen; } function frozenOf(address _user) public view returns (uint256) { return info.users[_user].frozen; } function dividendsOf(address _user) public view returns (uint256) { if(info.users[_user].staketime < MIN_DIVIDENDS_DUR){ return 0; }else{ return uint256(int256(info.scaledPayoutPerToken * info.users[_user].frozen) - info.users[_user].scaledPayout) / FLOAT_SCALAR; } } function userData(address _user) public view returns (uint256 totalTokensFrozen, uint256 userFrozen, uint256 userDividends, uint256 userStaketime, int256 scaledPayout) { return (totalFrozen(), frozenOf(_user), dividendsOf(_user), info.users[_user].staketime, info.users[_user].scaledPayout); } //======================================ACTION CALLS=========================================// function _stake(uint256 _amount) internal { require(stakingEnabled, "Staking not yet initialized"); require(IERC20(UniswapV2).balanceOf(msg.sender) >= _amount, "Insufficient SWAP AFT balance"); require(frozenOf(msg.sender) + _amount >= MINIMUM_STAKE, "Your amount is lower than the minimum amount allowed to stake"); require(IERC20(UniswapV2).allowance(msg.sender, address(this)) >= _amount, "Not enough allowance given to contract yet to spend by user"); info.users[msg.sender].staketime = now; info.totalFrozen += _amount; info.users[msg.sender].frozen += _amount; info.users[msg.sender].scaledPayout += int256(_amount * info.scaledPayoutPerToken); IERC20(UniswapV2).transferFrom(msg.sender, address(this), _amount); // Transfer liquidity tokens from the sender to this contract emit StakeEvent(msg.sender, address(this), _amount); } function _unstake(uint256 _amount) internal { require(frozenOf(msg.sender) >= _amount, "You currently do not have up to that amount staked"); info.totalFrozen -= _amount; info.users[msg.sender].frozen -= _amount; info.users[msg.sender].scaledPayout -= int256(_amount * info.scaledPayoutPerToken); require(IERC20(UniswapV2).transfer(msg.sender, _amount), "Transaction failed"); emit UnstakeEvent(address(this), msg.sender, _amount); } function TakeDividends() external returns (uint256) { uint256 _dividends = dividendsOf(msg.sender); require(_dividends >= 0, "you do not have any dividend yet"); info.users[msg.sender].scaledPayout += int256(_dividends * FLOAT_SCALAR); require(IERC20(Axiatoken).transfer(msg.sender, _dividends), "Transaction Failed"); // Transfer dividends to msg.sender emit RewardEvent(msg.sender, address(this), _dividends); return _dividends; } function scaledToken(uint _amount) external onlyAxiaToken returns(bool){ info.scaledPayoutPerToken += _amount * FLOAT_SCALAR / info.totalFrozen; infocheck = info.scaledPayoutPerToken; return true; } function mulDiv (uint x, uint y, uint z) public pure returns (uint) { (uint l, uint h) = fullMul (x, y); assert (h < z); uint mm = mulmod (x, y, z); if (mm > l) h -= 1; l -= mm; uint pow2 = z & -z; z /= pow2; l /= pow2; l += h * ((-pow2) / pow2 + 1); uint r = 1; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; r *= 2 - z * r; return l * r; } function fullMul (uint x, uint y) private pure returns (uint l, uint h) { uint mm = mulmod (x, y, uint (-1)); l = x * y; h = mm - l; if (mm < l) h -= 1; } }
0x608060405234801561001057600080fd5b50600436106101205760003560e01c806369c18e12116100ad578063ac3c853511610071578063ac3c8535146102b0578063b333de24146102cf578063b821b6bf146102d7578063c8910913146102df578063e0287b3e1461033057610120565b806369c18e12146102285780636b6b6aa4146102305780637640cb9e1461024d578063a43fc8711461026a578063aa9a09121461028757610120565b80631cfff51b116100f45780631cfff51b146101aa5780631e7f87bc146101c657806322701134146101ce578063376edab6146101f25780636387c9491461022057610120565b806265318b1461012557806308dbbb031461015d5780631495bf9a146101655780631bf6e00d14610184575b600080fd5b61014b6004803603602081101561013b57600080fd5b50356001600160a01b031661034d565b60408051918252519081900360200190f35b61014b6103b3565b6101826004803603602081101561017b57600080fd5b50356103b9565b005b61014b6004803603602081101561019a57600080fd5b50356001600160a01b03166103c5565b6101b26103e3565b604080519115158252519081900360200190f35b61014b6103f3565b6101d66103f9565b604080516001600160a01b039092168252519081900360200190f35b6101b26004803603604081101561020857600080fd5b506001600160a01b0381358116916020013516610408565b6101d6610530565b61014b61053f565b6101826004803603602081101561024657600080fd5b5035610545565b6101b26004803603602081101561026357600080fd5b503561054e565b6101826004803603602081101561028057600080fd5b50356105c3565b61014b6004803603606081101561029d57600080fd5b508035906020810135906040013561061b565b610182600480360360208110156102c657600080fd5b503515156106cf565b61014b6107ab565b61014b6108d5565b610305600480360360208110156102f557600080fd5b50356001600160a01b03166108db565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b6101826004803603602081101561034657600080fd5b5035610932565b600380546001600160a01b038316600090815260076020526040812090920154101561037b575060006103ae565b6001600160a01b03821660009081526007602052604090206002810154600190910154600854600160401b929102030490505b919050565b60025481565b6103c281610980565b50565b6001600160a01b031660009081526007602052604090206001015490565b600154600160a01b900460ff1681565b60065490565b6001546001600160a01b031681565b6009546000906001600160a01b031633146104545760405162461bcd60e51b8152600401808060200182810382526028815260200180610f216028913960400191505060405180910390fd5b816001600160a01b0316836001600160a01b031614156104a55760405162461bcd60e51b815260040180806020018281038252602a815260200180610f71602a913960400191505060405180910390fd5b6001600160a01b038316158015906104c557506001600160a01b03821615155b6105005760405162461bcd60e51b8152600401808060200182810382526028815260200180610f496028913960400191505060405180910390fd5b50600080546001600160a01b039384166001600160a01b0319918216179091556001805492909316911617815590565b6000546001600160a01b031681565b60045481565b6103c281610ca3565b600080546001600160a01b031633146105985760405162461bcd60e51b815260040180806020018281038252602b815260200180610e7e602b913960400191505060405180910390fd5b600654600160401b8302816105a957fe5b600880549290910490910190819055600455506001919050565b6009546001600160a01b0316331461060c5760405162461bcd60e51b8152600401808060200182810382526028815260200180610f216028913960400191505060405180910390fd5b670de0b6b3a764000002600255565b600080600061062a8686610e1e565b9150915083811061063757fe5b6000848061064157fe5b868809905082811115610655576001820391505b91829003916000859003851680868161066a57fe5b04955080848161067657fe5b04935080816000038161068557fe5b046001019290920292909201600285810380870282030280870282030280870282030280870282030280870282030280870282030295860290039094029390930295945050505050565b6009546001600160a01b031633146107185760405162461bcd60e51b8152600401808060200182810382526028815260200180610f216028913960400191505060405180910390fd5b6000546001600160a01b03161580159061073c57506001546001600160a01b031615155b61078d576040805162461bcd60e51b815260206004820181905260248201527f506f6f6c2061646472657373657320617265206e6f7420796574207365747570604482015290519081900360640190fd5b60018054911515600160a01b0260ff60a01b19909216919091179055565b6000806107b73361034d565b3360008181526007602090815260408083206002018054600160401b87020190558254815163a9059cbb60e01b815260048101959095526024850186905290519495506001600160a01b03169363a9059cbb93604480820194918390030190829087803b15801561082757600080fd5b505af115801561083b573d6000803e3d6000fd5b505050506040513d602081101561085157600080fd5b5051610899576040805162461bcd60e51b8152602060048201526012602482015271151c985b9cd858dd1a5bdb8811985a5b195960721b604482015290519081900360640190fd5b604080518281529051309133917f8c998377165b6abd6e99f8b84a86ed2c92d0055aeef42626fedea45c2909f6eb9181900360200190a3905090565b60035481565b60008060008060006108eb6103f3565b6108f4876103c5565b6108fd8861034d565b6001600160a01b0398909816600090815260076020526040902060038101546002909101549299919897509550909350915050565b6009546001600160a01b0316331461097b5760405162461bcd60e51b8152600401808060200182810382526028815260200180610f216028913960400191505060405180910390fd5b600355565b600154600160a01b900460ff166109de576040805162461bcd60e51b815260206004820152601b60248201527f5374616b696e67206e6f742079657420696e697469616c697a65640000000000604482015290519081900360640190fd5b600154604080516370a0823160e01b8152336004820152905183926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610a2857600080fd5b505afa158015610a3c573d6000803e3d6000fd5b505050506040513d6020811015610a5257600080fd5b50511015610aa7576040805162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e742053574150204146542062616c616e6365000000604482015290519081900360640190fd5b60025481610ab4336103c5565b011015610af25760405162461bcd60e51b815260040180806020018281038252603d815260200180610ee4603d913960400191505060405180910390fd5b60015460408051636eb1769f60e11b8152336004820152306024820152905183926001600160a01b03169163dd62ed3e916044808301926020929190829003018186803b158015610b4257600080fd5b505afa158015610b56573d6000803e3d6000fd5b505050506040513d6020811015610b6c57600080fd5b50511015610bab5760405162461bcd60e51b815260040180806020018281038252603b815260200180610ea9603b913960400191505060405180910390fd5b33600081815260076020908152604080832042600382015560068054870190556001808201805488019055600854600290920180549288029092019091555481516323b872dd60e01b815260048101959095523060248601526044850186905290516001600160a01b03909116936323b872dd9360648083019493928390030190829087803b158015610c3d57600080fd5b505af1158015610c51573d6000803e3d6000fd5b505050506040513d6020811015610c6757600080fd5b5050604080518281529051309133917f160ffcaa807f78c8b4983836e2396338d073e75695ac448aa0b5e4a75b210b1d9181900360200190a350565b80610cad336103c5565b1015610cea5760405162461bcd60e51b8152600401808060200182810382526032815260200180610e4c6032913960400191505060405180910390fd5b6006805482900390553360008181526007602090815260408083206001818101805488900390556008546002909201805492880290920390915554815163a9059cbb60e01b815260048101959095526024850186905290516001600160a01b039091169363a9059cbb9360448083019493928390030190829087803b158015610d7257600080fd5b505af1158015610d86573d6000803e3d6000fd5b505050506040513d6020811015610d9c57600080fd5b5051610de4576040805162461bcd60e51b8152602060048201526012602482015271151c985b9cd858dd1a5bdb8819985a5b195960721b604482015290519081900360640190fd5b604080518281529051339130917f15fba2c381f32b0e84d073dd1adb9edbcfd33a033ee48aaea415ac61ca7d448d9181900360200190a350565b6000808060001984860990508385029250828103915082811015610e43576001820391505b50925092905056fe596f752063757272656e746c7920646f206e6f74206861766520757020746f207468617420616d6f756e74207374616b6564417574686f72697a6174696f6e3a206f6e6c7920746f6b656e20636f6e74726163742063616e2063616c6c4e6f7420656e6f75676820616c6c6f77616e636520676976656e20746f20636f6e74726163742079657420746f207370656e642062792075736572596f757220616d6f756e74206973206c6f776572207468616e20746865206d696e696d756d20616d6f756e7420616c6c6f77656420746f207374616b654f776e61626c653a2063616c6c6572206973206e6f74207468652061646d696e6973747261746f72496e73657274696f6e206f662061646472657373283029206973206e6f7420737570706f72746564496e73657274696f6e206f662073616d652061646472657373206973206e6f7420737570706f72746564a264697066735822122089a9f100423e88fe3c74b9c78e12e3440758ce6afde987cb64ec52a6c713caa764736f6c63430006040033
[ 16, 4, 19 ]
0xf3C560A58b7b767513A9CbB051A210c2c5589180
/** *Submitted for verification at Etherscan.io on 2020-10-11 */ /** *Submitted for verification at Etherscan.io on 2020-09-13 */ /** *Submitted for verification at Etherscan.io on 2020-08-13 */ // SPDX-License-Identifier: MIT pragma solidity ^0.5.17; 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 decimals() external view returns (uint); function name() external view returns (string memory); 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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } 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"); } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } interface Controller { function vaults(address) external view returns (address); function rewards() external view returns (address); } /* A strategy must implement the following calls; - deposit() - withdraw(address) must exclude any tokens used in the yield - Controller role - withdraw should return to Controller - withdraw(uint) - Controller | Vault role - withdraw should always return to vault - withdrawAll() - Controller | Vault role - withdraw should always return to vault - balanceOf() Where possible, strategies must remain as immutable as possible, instead of updating variables, we update the contract by linking it in the controller */ interface UniswapRouter { function swapExactTokensForTokens(uint, uint, address[] calldata, address, uint) external; } interface For{ function deposit(address token, uint256 amount) external payable; function withdraw(address underlying, uint256 withdrawTokens) external; function withdrawUnderlying(address underlying, uint256 amount) external; function controller() view external returns(address); } interface IFToken { function balanceOf(address account) external view returns (uint256); function calcBalanceOfUnderlying(address owner) external view returns (uint256); } interface IBankController { function getFTokeAddress(address underlying) external view returns (address); } interface ForReward{ function claimReward() external; } contract StrategyFortube { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address constant public want = address(0xdAC17F958D2ee523a2206206994597C13D831ec7); //usdc address constant public output = address(0x1FCdcE58959f536621d76f5b7FfB955baa5A672F); //for address constant public unirouter = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); // used for for <> weth <> usdc route address constant public yfii = address(0x3BEDb00Cc64655a3ed60d21B8DFCc8463ad62bCF); address constant public fortube = address(0xdE7B3b2Fe0E7b4925107615A5b199a4EB40D9ca9);//主合约. address constant public fortube_reward = address(0xF8Df2E6E46AC00Cdf3616C4E35278b7704289d82); //领取奖励的合约 uint public strategyfee = 100; uint public fee = 300; uint public burnfee = 500; uint public callfee = 100; uint constant public max = 1000; uint public withdrawalFee = 0; uint constant public withdrawalMax = 10000; address public governance; address public strategyDev; address public controller; address public burnAddress = 0x5b3DabeEef7B346763689Dd776656d385803b824; string public getName; address[] public swap2YFIIRouting; address[] public swap2TokenRouting; constructor() public { governance = msg.sender; controller = 0xf90031e3030820b431f04C728aDE7199bA7Ff0B8; getName = string( abi.encodePacked("yfam:Strategy:", abi.encodePacked(IERC20(want).name(),"The Force Token" ) )); swap2YFIIRouting = [output,want,weth,yfii]; //for usdt weth yfii swap2TokenRouting = [output,want]; //for usdt doApprove(); strategyDev = tx.origin; } function doApprove () public{ IERC20(output).safeApprove(unirouter, 0); IERC20(output).safeApprove(unirouter, uint(-1)); } function deposit() public { uint _want = IERC20(want).balanceOf(address(this)); address _controller = For(fortube).controller(); if (_want > 0) { IERC20(want).safeApprove(_controller, 0); IERC20(want).safeApprove(_controller, _want); For(fortube).deposit(want,_want); } } // Controller only function for creating additional rewards from dust function withdraw(IERC20 _asset) external returns (uint balance) { require(msg.sender == controller, "!controller"); require(want != address(_asset), "want"); balance = _asset.balanceOf(address(this)); _asset.safeTransfer(controller, balance); } // Withdraw partial funds, normally used with a vault withdrawal function withdraw(uint _amount) external { require(msg.sender == controller, "!controller"); uint _balance = IERC20(want).balanceOf(address(this)); if (_balance < _amount) { _amount = _withdrawSome(_amount.sub(_balance)); _amount = _amount.add(_balance); } uint _fee = 0; if (withdrawalFee>0){ _fee = _amount.mul(withdrawalFee).div(withdrawalMax); IERC20(want).safeTransfer(Controller(controller).rewards(), _fee); } address _vault = Controller(controller).vaults(address(want)); require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_vault, _amount.sub(_fee)); } // Withdraw all funds, normally used when migrating strategies function withdrawAll() external returns (uint balance) { require(msg.sender == controller || msg.sender == governance,"!governance"); _withdrawAll(); balance = IERC20(want).balanceOf(address(this)); address _vault = Controller(controller).vaults(address(want)); require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds IERC20(want).safeTransfer(_vault, balance); } function _withdrawAll() internal { address _controller = For(fortube).controller(); IFToken fToken = IFToken(IBankController(_controller).getFTokeAddress(want)); uint b = fToken.balanceOf(address(this)); For(fortube).withdraw(want,b); } function harvest() public { require(msg.sender == strategyDev,"!"); ForReward(fortube_reward).claimReward(); doswap(); dosplit();//分yfii deposit(); } function doswap() internal { uint256 _2token = IERC20(output).balanceOf(address(this)).mul(90).div(100); //90% uint256 _2yfii = IERC20(output).balanceOf(address(this)).mul(10).div(100); //10% UniswapRouter(unirouter).swapExactTokensForTokens(_2token, 0, swap2TokenRouting, address(this), now.add(1800)); UniswapRouter(unirouter).swapExactTokensForTokens(_2yfii, 0, swap2YFIIRouting, address(this), now.add(1800)); } function dosplit() internal{ uint b = IERC20(yfii).balanceOf(address(this)); uint _fee = b.mul(fee).div(max); uint _callfee = b.mul(callfee).div(max); uint _burnfee = b.mul(burnfee).div(max); IERC20(yfii).safeTransfer(Controller(controller).rewards(), _fee); //3% 3% team IERC20(yfii).safeTransfer(msg.sender, _callfee); //call fee 1% IERC20(yfii).safeTransfer(burnAddress, _burnfee); //burn fee 5% if (strategyfee >0){ uint _strategyfee = b.mul(strategyfee).div(max); //1% IERC20(yfii).safeTransfer(strategyDev, _strategyfee); } } function _withdrawSome(uint256 _amount) internal returns (uint) { For(fortube).withdrawUnderlying(want,_amount); return _amount; } function balanceOfWant() public view returns (uint) { return IERC20(want).balanceOf(address(this)); } function balanceOfPool() public view returns (uint) { address _controller = For(fortube).controller(); IFToken fToken = IFToken(IBankController(_controller).getFTokeAddress(want)); return fToken.calcBalanceOfUnderlying(address(this)); } function balanceOf() public view returns (uint) { return balanceOfWant() .add(balanceOfPool()); } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function setController(address _controller) external { require(msg.sender == governance, "!governance"); controller = _controller; } function setFee(uint256 _fee) external{ require(msg.sender == governance, "!governance"); fee = _fee; } function setStrategyFee(uint256 _fee) external{ require(msg.sender == governance, "!governance"); strategyfee = _fee; } function setCallFee(uint256 _fee) external{ require(msg.sender == governance, "!governance"); callfee = _fee; } function setBurnFee(uint256 _fee) external{ require(msg.sender == governance, "!governance"); burnfee = _fee; } function setBurnAddress(address _burnAddress) public{ require(msg.sender == governance, "!governance"); burnAddress = _burnAddress; } function setWithdrawalFee(uint _withdrawalFee) external { require(msg.sender == governance, "!governance"); require(_withdrawalFee <=100,"fee >= 1%"); //max:1% withdrawalFee = _withdrawalFee; } function setSwap2YFII(address[] memory _path) public{ require(msg.sender == governance, "!governance"); swap2YFIIRouting = _path; } function setSwap2Token(address[] memory _path) public{ require(msg.sender == governance, "!governance"); swap2TokenRouting = _path; } }
0x608060405234801561001057600080fd5b50600436106102485760003560e01c80636ac3feee1161013b578063b97907a8116100b8578063d5c1ff731161007c578063d5c1ff7314610afc578063dba11a6d14610b1a578063ddca3f4314610b38578063f20eaeb814610b56578063f77c479114610ba057610248565b8063b97907a814610a22578063becacda614610a40578063c1a3d44c14610a8a578063d0e30db014610aa8578063d2a9d86214610ab257610248565b8063853828b6116100ff578063853828b6146109305780638bc7e8c41461094e57806392eefe9b1461096c578063ab033ea9146109b0578063ac1e5025146109f457610248565b80636ac3feee146108325780636ac5db191461087c5780636ec889761461089a57806370d5ae05146108c8578063722713f71461091257610248565b80633fc8cef3116101c957806351cff8d91161018d57806351cff8d9146106a05780635aa6e675146106f85780635af82719146107425780635bb5ebbe146107fa57806369fe0e2d1461080457610248565b80633fc8cef3146105905780634641257d146105da5780634645b110146105e45780634b0e72161461062e5780634bf2c7c91461067257610248565b80631f1fcd51116102105780631f1fcd51146103e8578063211213f014610432578063257ae0de146104ea57806326465826146105345780632e1a7d4d1461056257610248565b8063037263571461024d578063115880861461026b57806312ed71531461028957806317bb7272146102f757806317d7de7c14610365575b600080fd5b610255610bea565b6040518082815260200191505060405180910390f35b610273610bf0565b6040518082815260200191505060405180910390f35b6102b56004803603602081101561029f57600080fd5b8101908080359060200190929190505050610e19565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103236004803603602081101561030d57600080fd5b8101908080359060200190929190505050610e55565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61036d610e91565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ad578082015181840152602081019050610392565b50505050905090810190601f1680156103da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103f0610f2f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104e86004803603602081101561044857600080fd5b810190808035906020019064010000000081111561046557600080fd5b82018360208201111561047757600080fd5b8035906020019184602083028401116401000000008311171561049957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610f47565b005b6104f2611024565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105606004803603602081101561054a57600080fd5b810190808035906020019092919050505061103c565b005b61058e6004803603602081101561057857600080fd5b8101908080359060200190929190505050611109565b005b6105986115e0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105e26115f8565b005b6105ec611749565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106706004803603602081101561064457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611761565b005b61069e6004803603602081101561068857600080fd5b8101908080359060200190929190505050611868565b005b6106e2600480360360208110156106b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611935565b6040518082815260200191505060405180910390f35b610700611bbc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107f86004803603602081101561075857600080fd5b810190808035906020019064010000000081111561077557600080fd5b82018360208201111561078757600080fd5b803590602001918460208302840111640100000000831117156107a957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611be2565b005b610802611cbf565b005b6108306004803603602081101561081a57600080fd5b8101908080359060200190929190505050611d88565b005b61083a611e55565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610884611e6d565b6040518082815260200191505060405180910390f35b6108c6600480360360208110156108b057600080fd5b8101908080359060200190929190505050611e73565b005b6108d0611f40565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61091a611f66565b6040518082815260200191505060405180910390f35b610938611f8e565b6040518082815260200191505060405180910390f35b610956612359565b6040518082815260200191505060405180910390f35b6109ae6004803603602081101561098257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061235f565b005b6109f2600480360360208110156109c657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612466565b005b610a2060048036036020811015610a0a57600080fd5b810190808035906020019092919050505061256d565b005b610a2a6126b1565b6040518082815260200191505060405180910390f35b610a486126b7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610a926126dd565b6040518082815260200191505060405180910390f35b610ab06127b0565b005b610aba612a6d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610b04612a85565b6040518082815260200191505060405180910390f35b610b22612a8b565b6040518082815260200191505060405180910390f35b610b40612a91565b6040518082815260200191505060405180910390f35b610b5e612a97565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610ba8612aaf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60025481565b60008073de7b3b2fe0e7b4925107615a5b199a4eb40d9ca973ffffffffffffffffffffffffffffffffffffffff1663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4d57600080fd5b505afa158015610c61573d6000803e3d6000fd5b505050506040513d6020811015610c7757600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663fc1ce70873dac17f958d2ee523a2206206994597c13d831ec76040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610d1d57600080fd5b505afa158015610d31573d6000803e3d6000fd5b505050506040513d6020811015610d4757600080fd5b810190808051906020019092919050505090508073ffffffffffffffffffffffffffffffffffffffff1663e61de305306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610dd757600080fd5b505afa158015610deb573d6000803e3d6000fd5b505050506040513d6020811015610e0157600080fd5b81019080805190602001909291905050509250505090565b600b8181548110610e2657fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a8181548110610e6257fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60098054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f275780601f10610efc57610100808354040283529160200191610f27565b820191906000526020600020905b815481529060010190602001808311610f0a57829003601f168201915b505050505081565b73dac17f958d2ee523a2206206994597c13d831ec781565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600a9080519060200190611020929190613f58565b5050565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b8060038190555050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146111cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21636f6e74726f6c6c657200000000000000000000000000000000000000000081525060200191505060405180910390fd5b600073dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561125f57600080fd5b505afa158015611273573d6000803e3d6000fd5b505050506040513d602081101561128957600080fd5b81019080805190602001909291905050509050818110156112d7576112bf6112ba8284612ad590919063ffffffff16565b612b1f565b91506112d48183612bf090919063ffffffff16565b91505b6000809050600060045411156113f45761131061271061130260045486612c7890919063ffffffff16565b612cfe90919063ffffffff16565b90506113f3600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b15801561137d57600080fd5b505afa158015611391573d6000803e3d6000fd5b505050506040513d60208110156113a757600080fd5b81019080805190602001909291905050508273dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b5b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a622ee7c73dac17f958d2ee523a2206206994597c13d831ec76040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156114a957600080fd5b505afa1580156114bd573d6000803e3d6000fd5b505050506040513d60208110156114d357600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611589576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f217661756c74000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b6115da816115a08487612ad590919063ffffffff16565b73dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b50505050565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146116bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260018152602001807f210000000000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b73f8df2e6e46ac00cdf3616c4e35278b7704289d8273ffffffffffffffffffffffffffffffffffffffff1663b88a802f6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561171757600080fd5b505af115801561172b573d6000803e3d6000fd5b50505050611737612e19565b61173f6132b3565b6117476127b0565b565b73de7b3b2fe0e7b4925107615a5b199a4eb40d9ca981565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611824576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461192b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b8060028190555050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146119fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21636f6e74726f6c6c657200000000000000000000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1673dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff161415611ab0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f77616e740000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611b2d57600080fd5b505afa158015611b41573d6000803e3d6000fd5b505050506040513d6020811015611b5757600080fd5b81019080805190602001909291905050509050611bb7600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828473ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611ca5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b9080519060200190611cbb929190613f58565b5050565b611d13737a250d5630b4cf539739df2c5dacb4c659f2488d6000731fcdce58959f536621d76f5b7ffb955baa5a672f73ffffffffffffffffffffffffffffffffffffffff1661362b9092919063ffffffff16565b611d86737a250d5630b4cf539739df2c5dacb4c659f2488d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff731fcdce58959f536621d76f5b7ffb955baa5a672f73ffffffffffffffffffffffffffffffffffffffff1661362b9092919063ffffffff16565b565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611e4b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b8060018190555050565b73f8df2e6e46ac00cdf3616c4e35278b7704289d8281565b6103e881565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611f36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b8060008190555050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000611f89611f73610bf0565b611f7b6126dd565b612bf090919063ffffffff16565b905090565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806120395750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6120ab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b6120b361384b565b73dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561214457600080fd5b505afa158015612158573d6000803e3d6000fd5b505050506040513d602081101561216e57600080fd5b810190808051906020019092919050505090506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a622ee7c73dac17f958d2ee523a2206206994597c13d831ec76040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561223657600080fd5b505afa15801561224a573d6000803e3d6000fd5b505050506040513d602081101561226057600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612316576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f217661756c74000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b612355818373dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b5090565b60045481565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612422576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612529576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612630576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600b8152602001807f21676f7665726e616e636500000000000000000000000000000000000000000081525060200191505060405180910390fd5b60648111156126a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f666565203e3d203125000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b8060048190555050565b60005481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600073dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561277057600080fd5b505afa158015612784573d6000803e3d6000fd5b505050506040513d602081101561279a57600080fd5b8101908080519060200190929190505050905090565b600073dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561284357600080fd5b505afa158015612857573d6000803e3d6000fd5b505050506040513d602081101561286d57600080fd5b81019080805190602001909291905050509050600073de7b3b2fe0e7b4925107615a5b199a4eb40d9ca973ffffffffffffffffffffffffffffffffffffffff1663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156128dc57600080fd5b505afa1580156128f0573d6000803e3d6000fd5b505050506040513d602081101561290657600080fd5b810190808051906020019092919050505090506000821115612a695761296281600073dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1661362b9092919063ffffffff16565b6129a1818373dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1661362b9092919063ffffffff16565b73de7b3b2fe0e7b4925107615a5b199a4eb40d9ca973ffffffffffffffffffffffffffffffffffffffff166347e7ef2473dac17f958d2ee523a2206206994597c13d831ec7846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015612a5057600080fd5b505af1158015612a64573d6000803e3d6000fd5b505050505b5050565b733bedb00cc64655a3ed60d21b8dfcc8463ad62bcf81565b61271081565b60035481565b60015481565b731fcdce58959f536621d76f5b7ffb955baa5a672f81565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000612b1783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613b3c565b905092915050565b600073de7b3b2fe0e7b4925107615a5b199a4eb40d9ca973ffffffffffffffffffffffffffffffffffffffff1663fdb8725273dac17f958d2ee523a2206206994597c13d831ec7846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015612bd057600080fd5b505af1158015612be4573d6000803e3d6000fd5b50505050819050919050565b600080828401905083811015612c6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415612c8b5760009050612cf8565b6000828402905082848281612c9c57fe5b0414612cf3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806140266021913960400191505060405180910390fd5b809150505b92915050565b6000612d4083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613bfc565b905092915050565b612e14838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613cc2565b505050565b6000612f0d6064612eff605a731fcdce58959f536621d76f5b7ffb955baa5a672f73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612eb657600080fd5b505afa158015612eca573d6000803e3d6000fd5b505050506040513d6020811015612ee057600080fd5b8101908080519060200190929190505050612c7890919063ffffffff16565b612cfe90919063ffffffff16565b905060006130036064612ff5600a731fcdce58959f536621d76f5b7ffb955baa5a672f73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015612fac57600080fd5b505afa158015612fc0573d6000803e3d6000fd5b505050506040513d6020811015612fd657600080fd5b8101908080519060200190929190505050612c7890919063ffffffff16565b612cfe90919063ffffffff16565b9050737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff166338ed1739836000600b3061305061070842612bf090919063ffffffff16565b6040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818154815260200191508054801561311e57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116130d4575b50509650505050505050600060405180830381600087803b15801561314257600080fd5b505af1158015613156573d6000803e3d6000fd5b50505050737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff166338ed1739826000600a306131a561070842612bf090919063ffffffff16565b6040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818154815260200191508054801561327357602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311613229575b50509650505050505050600060405180830381600087803b15801561329757600080fd5b505af11580156132ab573d6000803e3d6000fd5b505050505050565b6000733bedb00cc64655a3ed60d21b8dfcc8463ad62bcf73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561334657600080fd5b505afa15801561335a573d6000803e3d6000fd5b505050506040513d602081101561337057600080fd5b8101908080519060200190929190505050905060006133ae6103e86133a060015485612c7890919063ffffffff16565b612cfe90919063ffffffff16565b905060006133db6103e86133cd60035486612c7890919063ffffffff16565b612cfe90919063ffffffff16565b905060006134086103e86133fa60025487612c7890919063ffffffff16565b612cfe90919063ffffffff16565b90506134eb600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639ec5a8946040518163ffffffff1660e01b815260040160206040518083038186803b15801561347557600080fd5b505afa158015613489573d6000803e3d6000fd5b505050506040513d602081101561349f57600080fd5b810190808051906020019092919050505084733bedb00cc64655a3ed60d21b8dfcc8463ad62bcf73ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b61352a3383733bedb00cc64655a3ed60d21b8dfcc8463ad62bcf73ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b61358b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682733bedb00cc64655a3ed60d21b8dfcc8463ad62bcf73ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b6000805411156136255760006135c06103e86135b260005488612c7890919063ffffffff16565b612cfe90919063ffffffff16565b9050613623600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682733bedb00cc64655a3ed60d21b8dfcc8463ad62bcf73ffffffffffffffffffffffffffffffffffffffff16612d489092919063ffffffff16565b505b50505050565b6000811480613725575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b1580156136e857600080fd5b505afa1580156136fc573d6000803e3d6000fd5b505050506040513d602081101561371257600080fd5b8101908080519060200190929190505050145b61377a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806140716036913960400191505060405180910390fd5b613846838473ffffffffffffffffffffffffffffffffffffffff1663095ea7b3905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050613cc2565b505050565b600073de7b3b2fe0e7b4925107615a5b199a4eb40d9ca973ffffffffffffffffffffffffffffffffffffffff1663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b1580156138a757600080fd5b505afa1580156138bb573d6000803e3d6000fd5b505050506040513d60208110156138d157600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff1663fc1ce70873dac17f958d2ee523a2206206994597c13d831ec76040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561397757600080fd5b505afa15801561398b573d6000803e3d6000fd5b505050506040513d60208110156139a157600080fd5b8101908080519060200190929190505050905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015613a3357600080fd5b505afa158015613a47573d6000803e3d6000fd5b505050506040513d6020811015613a5d57600080fd5b8101908080519060200190929190505050905073de7b3b2fe0e7b4925107615a5b199a4eb40d9ca973ffffffffffffffffffffffffffffffffffffffff1663f3fef3a373dac17f958d2ee523a2206206994597c13d831ec7836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015613b1f57600080fd5b505af1158015613b33573d6000803e3d6000fd5b50505050505050565b6000838311158290613be9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613bae578082015181840152602081019050613b93565b50505050905090810190601f168015613bdb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290613ca8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613c6d578082015181840152602081019050613c52565b50505050905090810190601f168015613c9a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581613cb457fe5b049050809150509392505050565b613ce18273ffffffffffffffffffffffffffffffffffffffff16613f0d565b613d53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310613da25780518252602082019150602081019050602083039250613d7f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613e04576040519150601f19603f3d011682016040523d82523d6000602084013e613e09565b606091505b509150915081613e81576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115613f0757808060200190516020811015613ea057600080fd5b8101908080519060200190929190505050613f06576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614047602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b8214158015613f4f5750808214155b92505050919050565b828054828255906000526020600020908101928215613fd1579160200282015b82811115613fd05782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190613f78565b5b509050613fde9190613fe2565b5090565b61402291905b8082111561401e57600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101613fe8565b5090565b9056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a723158203550a192c0d670c50c32cb986efec41184bf98471e890ebe66c985f91244be9c64736f6c63430005110032
[ 38 ]
0xf3c6327B4c58e38A7986Edb4a8F236031708f280
// File: @openzeppelin/contracts/access/IAccessControl.sol // 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; } // 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/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/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/access/AccessControl.sol // OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @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()); } } } // 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: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.1 (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/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.1 (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/HATAYToken.sol //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract HATAYToken is ERC20, AccessControl { string private __name = "Hatayspor Token"; string private __symbol = "HATAY"; uint8 private __decimals = 2; uint private __INITIAL_SUPPLY = 3100000000; bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); event Burned(address addr, uint256 amount); constructor() public ERC20(__name, __symbol) { _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(BURNER_ROLE, msg.sender); _mint(msg.sender, __INITIAL_SUPPLY); } function burn(address from, uint256 amount) public { require(hasRole(BURNER_ROLE, _msgSender()), "HATAY Token: Caller is not a burner"); _burn(from, amount); emit Burned(from, amount); } function decimals() public view virtual override returns (uint8) { return __decimals; } }
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806339509351116100ad578063a217fddf11610071578063a217fddf1461036b578063a457c2d714610389578063a9059cbb146103b9578063d547741f146103e9578063dd62ed3e146104055761012c565b806339509351146102a157806370a08231146102d157806391d148541461030157806395d89b41146103315780639dc29fac1461034f5761012c565b8063248a9ca3116100f4578063248a9ca3146101fd578063282c51f31461022d5780632f2ff15d1461024b578063313ce5671461026757806336568abe146102855761012c565b806301ffc9a71461013157806306fdde0314610161578063095ea7b31461017f57806318160ddd146101af57806323b872dd146101cd575b600080fd5b61014b60048036038101906101469190611972565b610435565b6040516101589190611fd5565b60405180910390f35b6101696104af565b604051610176919061200b565b60405180910390f35b610199600480360381019061019491906118d1565b610541565b6040516101a69190611fd5565b60405180910390f35b6101b761055f565b6040516101c491906121ad565b60405180910390f35b6101e760048036038101906101e29190611882565b610569565b6040516101f49190611fd5565b60405180910390f35b6102176004803603810190610212919061190d565b610661565b6040516102249190611ff0565b60405180910390f35b610235610681565b6040516102429190611ff0565b60405180910390f35b61026560048036038101906102609190611936565b6106a5565b005b61026f6106ce565b60405161027c91906121c8565b60405180910390f35b61029f600480360381019061029a9190611936565b6106e5565b005b6102bb60048036038101906102b691906118d1565b610768565b6040516102c89190611fd5565b60405180910390f35b6102eb60048036038101906102e6919061181d565b610814565b6040516102f891906121ad565b60405180910390f35b61031b60048036038101906103169190611936565b61085c565b6040516103289190611fd5565b60405180910390f35b6103396108c7565b604051610346919061200b565b60405180910390f35b610369600480360381019061036491906118d1565b610959565b005b610373610a10565b6040516103809190611ff0565b60405180910390f35b6103a3600480360381019061039e91906118d1565b610a17565b6040516103b09190611fd5565b60405180910390f35b6103d360048036038101906103ce91906118d1565b610b02565b6040516103e09190611fd5565b60405180910390f35b61040360048036038101906103fe9190611936565b610b20565b005b61041f600480360381019061041a9190611846565b610b49565b60405161042c91906121ad565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104a857506104a782610bd0565b5b9050919050565b6060600380546104be906123d6565b80601f01602080910402602001604051908101604052809291908181526020018280546104ea906123d6565b80156105375780601f1061050c57610100808354040283529160200191610537565b820191906000526020600020905b81548152906001019060200180831161051a57829003601f168201915b5050505050905090565b600061055561054e610c3a565b8484610c42565b6001905092915050565b6000600254905090565b6000610576848484610e0d565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105c1610c3a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610641576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610638906120ed565b60405180910390fd5b6106558561064d610c3a565b858403610c42565b60019150509392505050565b600060056000838152602001908152602001600020600101549050919050565b7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a84881565b6106ae82610661565b6106bf816106ba610c3a565b61108e565b6106c9838361112b565b505050565b6000600860009054906101000a900460ff16905090565b6106ed610c3a565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461075a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107519061218d565b60405180910390fd5b610764828261120c565b5050565b600061080a610775610c3a565b848460016000610783610c3a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610805919061220a565b610c42565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6060600480546108d6906123d6565b80601f0160208091040260200160405190810160405280929190818152602001828054610902906123d6565b801561094f5780601f106109245761010080835404028352916020019161094f565b820191906000526020600020905b81548152906001019060200180831161093257829003601f168201915b5050505050905090565b61098a7f3c11d16cbaffd01df69ce1c404f6340ee057498f5f00246190ea54220576a848610985610c3a565b61085c565b6109c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c0906120cd565b60405180910390fd5b6109d382826112ee565b7f696de425f79f4a40bc6d2122ca50507f0efbeabbff86a84871b7196ab8ea8df78282604051610a04929190611fac565b60405180910390a15050565b6000801b81565b60008060016000610a26610c3a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610ae3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ada9061216d565b60405180910390fd5b610af7610aee610c3a565b85858403610c42565b600191505092915050565b6000610b16610b0f610c3a565b8484610e0d565b6001905092915050565b610b2982610661565b610b3a81610b35610c3a565b61108e565b610b44838361120c565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca99061214d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d199061208d565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610e0091906121ad565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e749061212d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610eed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee49061204d565b60405180910390fd5b610ef88383836114c5565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610f7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f75906120ad565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611011919061220a565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161107591906121ad565b60405180910390a36110888484846114ca565b50505050565b611098828261085c565b611127576110bd8173ffffffffffffffffffffffffffffffffffffffff1660146114cf565b6110cb8360001c60206114cf565b6040516020016110dc929190611f72565b6040516020818303038152906040526040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111e919061200b565b60405180910390fd5b5050565b611135828261085c565b6112085760016005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506111ad610c3a565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b611216828261085c565b156112ea5760006005600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061128f610c3a565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561135e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113559061210d565b60405180910390fd5b61136a826000836114c5565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156113f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e79061206d565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816002600082825461144791906122ba565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516114ac91906121ad565b60405180910390a36114c0836000846114ca565b505050565b505050565b505050565b6060600060028360026114e29190612260565b6114ec919061220a565b67ffffffffffffffff81111561152b577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561155d5781602001600182028036833780820191505090505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106115bb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611645577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600060018460026116859190612260565b61168f919061220a565b90505b600181111561177b577f3031323334353637383961626364656600000000000000000000000000000000600f8616601081106116f7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a60f81b828281518110611734577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c945080611774906123ac565b9050611692565b50600084146117bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b69061202d565b60405180910390fd5b8091505092915050565b6000813590506117d881612477565b92915050565b6000813590506117ed8161248e565b92915050565b600081359050611802816124a5565b92915050565b600081359050611817816124bc565b92915050565b60006020828403121561182f57600080fd5b600061183d848285016117c9565b91505092915050565b6000806040838503121561185957600080fd5b6000611867858286016117c9565b9250506020611878858286016117c9565b9150509250929050565b60008060006060848603121561189757600080fd5b60006118a5868287016117c9565b93505060206118b6868287016117c9565b92505060406118c786828701611808565b9150509250925092565b600080604083850312156118e457600080fd5b60006118f2858286016117c9565b925050602061190385828601611808565b9150509250929050565b60006020828403121561191f57600080fd5b600061192d848285016117de565b91505092915050565b6000806040838503121561194957600080fd5b6000611957858286016117de565b9250506020611968858286016117c9565b9150509250929050565b60006020828403121561198457600080fd5b6000611992848285016117f3565b91505092915050565b6119a4816122ee565b82525050565b6119b381612300565b82525050565b6119c28161230c565b82525050565b60006119d3826121e3565b6119dd81856121ee565b93506119ed818560208601612379565b6119f681612466565b840191505092915050565b6000611a0c826121e3565b611a1681856121ff565b9350611a26818560208601612379565b80840191505092915050565b6000611a3f6020836121ee565b91507f537472696e67733a20686578206c656e67746820696e73756666696369656e746000830152602082019050919050565b6000611a7f6023836121ee565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611ae56022836121ee565b91507f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008301527f63650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611b4b6022836121ee565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611bb16026836121ee565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611c176023836121ee565b91507f484154415920546f6b656e3a2043616c6c6572206973206e6f7420612062757260008301527f6e657200000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611c7d6028836121ee565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611ce36021836121ee565b91507f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008301527f73000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611d496025836121ee565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611daf6024836121ee565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611e156017836121ff565b91507f416363657373436f6e74726f6c3a206163636f756e74200000000000000000006000830152601782019050919050565b6000611e556025836121ee565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611ebb6011836121ff565b91507f206973206d697373696e6720726f6c65200000000000000000000000000000006000830152601182019050919050565b6000611efb602f836121ee565b91507f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008301527f20726f6c657320666f722073656c6600000000000000000000000000000000006020830152604082019050919050565b611f5d81612362565b82525050565b611f6c8161236c565b82525050565b6000611f7d82611e08565b9150611f898285611a01565b9150611f9482611eae565b9150611fa08284611a01565b91508190509392505050565b6000604082019050611fc1600083018561199b565b611fce6020830184611f54565b9392505050565b6000602082019050611fea60008301846119aa565b92915050565b600060208201905061200560008301846119b9565b92915050565b6000602082019050818103600083015261202581846119c8565b905092915050565b6000602082019050818103600083015261204681611a32565b9050919050565b6000602082019050818103600083015261206681611a72565b9050919050565b6000602082019050818103600083015261208681611ad8565b9050919050565b600060208201905081810360008301526120a681611b3e565b9050919050565b600060208201905081810360008301526120c681611ba4565b9050919050565b600060208201905081810360008301526120e681611c0a565b9050919050565b6000602082019050818103600083015261210681611c70565b9050919050565b6000602082019050818103600083015261212681611cd6565b9050919050565b6000602082019050818103600083015261214681611d3c565b9050919050565b6000602082019050818103600083015261216681611da2565b9050919050565b6000602082019050818103600083015261218681611e48565b9050919050565b600060208201905081810360008301526121a681611eee565b9050919050565b60006020820190506121c26000830184611f54565b92915050565b60006020820190506121dd6000830184611f63565b92915050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600061221582612362565b915061222083612362565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561225557612254612408565b5b828201905092915050565b600061226b82612362565b915061227683612362565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156122af576122ae612408565b5b828202905092915050565b60006122c582612362565b91506122d083612362565b9250828210156122e3576122e2612408565b5b828203905092915050565b60006122f982612342565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561239757808201518184015260208101905061237c565b838111156123a6576000848401525b50505050565b60006123b782612362565b915060008214156123cb576123ca612408565b5b600182039050919050565b600060028204905060018216806123ee57607f821691505b6020821081141561240257612401612437565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b612480816122ee565b811461248b57600080fd5b50565b6124978161230c565b81146124a257600080fd5b50565b6124ae81612316565b81146124b957600080fd5b50565b6124c581612362565b81146124d057600080fd5b5056fea264697066735822122024474ab041f3b03320d4d933efe6b35086a8f2d9171575e4ff1fd9f859f5f92d64736f6c63430008000033
[ 38 ]
0xf3c638006c94baf926f1b9e8ed4e6b0259ac73f8
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract FakeToken is ERC20 { constructor() ERC20("fakeToken", "FAKE") { _mint(msg.sender, 1 * 10**decimals()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (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: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, 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: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _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 Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/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; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461016857806370a082311461019857806395d89b41146101c8578063a457c2d7146101e6578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a578063313ce5671461014a575b600080fd5b6100b6610276565b6040516100c39190610dff565b60405180910390f35b6100e660048036038101906100e19190610c4d565b610308565b6040516100f39190610de4565b60405180910390f35b61010461032b565b6040516101119190610f01565b60405180910390f35b610134600480360381019061012f9190610bfe565b610335565b6040516101419190610de4565b60405180910390f35b610152610364565b60405161015f9190610f1c565b60405180910390f35b610182600480360381019061017d9190610c4d565b61036d565b60405161018f9190610de4565b60405180910390f35b6101b260048036038101906101ad9190610b99565b610417565b6040516101bf9190610f01565b60405180910390f35b6101d061045f565b6040516101dd9190610dff565b60405180910390f35b61020060048036038101906101fb9190610c4d565b6104f1565b60405161020d9190610de4565b60405180910390f35b610230600480360381019061022b9190610c4d565b6105db565b60405161023d9190610de4565b60405180910390f35b610260600480360381019061025b9190610bc2565b6105fe565b60405161026d9190610f01565b60405180910390f35b60606003805461028590611031565b80601f01602080910402602001604051908101604052809291908181526020018280546102b190611031565b80156102fe5780601f106102d3576101008083540402835291602001916102fe565b820191906000526020600020905b8154815290600101906020018083116102e157829003601f168201915b5050505050905090565b600080610313610685565b905061032081858561068d565b600191505092915050565b6000600254905090565b600080610340610685565b905061034d858285610858565b6103588585856108e4565b60019150509392505050565b60006012905090565b600080610378610685565b905061040c818585600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104079190610f53565b61068d565b600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461046e90611031565b80601f016020809104026020016040519081016040528092919081815260200182805461049a90611031565b80156104e75780601f106104bc576101008083540402835291602001916104e7565b820191906000526020600020905b8154815290600101906020018083116104ca57829003601f168201915b5050505050905090565b6000806104fc610685565b90506000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050838110156105c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105b990610ee1565b60405180910390fd5b6105cf828686840361068d565b60019250505092915050565b6000806105e6610685565b90506105f38185856108e4565b600191505092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156106fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f490610ec1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561076d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076490610e41565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161084b9190610f01565b60405180910390a3505050565b600061086484846105fe565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146108de57818110156108d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c790610e61565b60405180910390fd5b6108dd848484840361068d565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610954576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094b90610ea1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156109c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109bb90610e21565b60405180910390fd5b6109cf838383610b65565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610a55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4c90610e81565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ae89190610f53565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b4c9190610f01565b60405180910390a3610b5f848484610b6a565b50505050565b505050565b505050565b600081359050610b7e816112d5565b92915050565b600081359050610b93816112ec565b92915050565b600060208284031215610bab57600080fd5b6000610bb984828501610b6f565b91505092915050565b60008060408385031215610bd557600080fd5b6000610be385828601610b6f565b9250506020610bf485828601610b6f565b9150509250929050565b600080600060608486031215610c1357600080fd5b6000610c2186828701610b6f565b9350506020610c3286828701610b6f565b9250506040610c4386828701610b84565b9150509250925092565b60008060408385031215610c6057600080fd5b6000610c6e85828601610b6f565b9250506020610c7f85828601610b84565b9150509250929050565b610c9281610fbb565b82525050565b6000610ca382610f37565b610cad8185610f42565b9350610cbd818560208601610ffe565b610cc6816110c1565b840191505092915050565b6000610cde602383610f42565b9150610ce9826110d2565b604082019050919050565b6000610d01602283610f42565b9150610d0c82611121565b604082019050919050565b6000610d24601d83610f42565b9150610d2f82611170565b602082019050919050565b6000610d47602683610f42565b9150610d5282611199565b604082019050919050565b6000610d6a602583610f42565b9150610d75826111e8565b604082019050919050565b6000610d8d602483610f42565b9150610d9882611237565b604082019050919050565b6000610db0602583610f42565b9150610dbb82611286565b604082019050919050565b610dcf81610fe7565b82525050565b610dde81610ff1565b82525050565b6000602082019050610df96000830184610c89565b92915050565b60006020820190508181036000830152610e198184610c98565b905092915050565b60006020820190508181036000830152610e3a81610cd1565b9050919050565b60006020820190508181036000830152610e5a81610cf4565b9050919050565b60006020820190508181036000830152610e7a81610d17565b9050919050565b60006020820190508181036000830152610e9a81610d3a565b9050919050565b60006020820190508181036000830152610eba81610d5d565b9050919050565b60006020820190508181036000830152610eda81610d80565b9050919050565b60006020820190508181036000830152610efa81610da3565b9050919050565b6000602082019050610f166000830184610dc6565b92915050565b6000602082019050610f316000830184610dd5565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610f5e82610fe7565b9150610f6983610fe7565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610f9e57610f9d611063565b5b828201905092915050565b6000610fb482610fc7565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561101c578082015181840152602081019050611001565b8381111561102b576000848401525b50505050565b6000600282049050600182168061104957607f821691505b6020821081141561105d5761105c611092565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6112de81610fa9565b81146112e957600080fd5b50565b6112f581610fe7565b811461130057600080fd5b5056fea2646970667358221220bc3258e765bd8b2b8cd9965c08c356fdff3777822912a0b9490904cf17f2f09a64736f6c63430008040033
[ 38 ]
0xf3c6586e56c0c595749b8b75ac2a888d20bb48da
// File: contracts/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) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } // File: contracts/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 in existence. */ /** * @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. * * > 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/contracts/utils/Address.sol pragma solidity ^0.5.0; /** * @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. * * > 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. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } // File: contracts/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); 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/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 aplied to your functions to restrict their use to * the owner. */ contract Ownable { 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 = msg.sender; 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 msg.sender == _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/TokenPool.sol pragma solidity 0.5.16; /** * @title A simple holder of tokens. * This is a simple contract to hold tokens. It's useful in the case where a separate contract * needs to hold multiple distinct pools of the same token. */ contract TokenPool is Ownable { IERC20 public token; constructor(IERC20 _token) public { token = _token; } function balance() public view returns (uint256) { return token.balanceOf(address(this)); } function transfer(address to, uint256 value) external onlyOwner returns (bool) { return token.transfer(to, value); } function rescueFunds(address tokenToRescue, address to, uint256 amount) external onlyOwner returns (bool) { require(address(token) != tokenToRescue, 'TokenPool: Cannot claim token held by the contract'); return IERC20(tokenToRescue).transfer(to, amount); } } // File: contracts/LiquidityMining.sol pragma solidity 0.5.16; pragma experimental ABIEncoderV2; /** * @title Token Geyser * @dev A smart-contract based mechanism to distribute tokens over time, inspired loosely by * Compound and Uniswap. * * Distribution tokens are added to a locked pool in the contract and become unlocked over time * according to a once-configurable unlock schedule. Once unlocked, they are available to be * claimed by users. * * A user may deposit tokens to accrue ownership share over the unlocked pool. This owner share * is a function of the number of tokens deposited as well as the length of time deposited. * Specifically, a user's share of the currently-unlocked pool equals their "deposit-seconds" * divided by the global "deposit-seconds". This aligns the new token distribution with long * term supporters of the project, addressing one of the major drawbacks of simple airdrops. * * More background and motivation available at: * https://github.com/ampleforth/RFCs/blob/master/RFCs/rfc-1.md */ contract LiquidityMining is Ownable { using SafeMath for uint256; event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked( address indexed user, uint256 amount, uint256 total, bytes data ); event TokensClaimed(address indexed user, uint256 amount); event TokensLocked(uint256 amount, uint256 durationSec, uint256 total); // amount: Unlocked tokens, total: Total locked tokens event TokensUnlocked(uint256 amount, uint256 total); TokenPool private _stakingPool; TokenPool private _unlockedPool; TokenPool private _lockedPool; // // Time-bonus params // uint256 public constant BONUS_DECIMALS = 2; uint256 public startBonus = 0; uint256 public bonusPeriodSec = 0; // // Global accounting state // uint256 public totalLockedShares = 0; uint256 public totalStakingShares = 0; uint256 private _totalStakingShareSeconds = 0; uint256 private _lastAccountingTimestampSec = now; uint256 private _maxUnlockSchedules = 0; uint256 private _initialSharesPerToken = 0; // // User accounting state // // Represents a single stake for a user. A user may have multiple. struct Stake { uint256 stakingShares; uint256 timestampSec; } // Caches aggregated values from the User->Stake[] map to save computation. // If lastAccountingTimestampSec is 0, there's no entry for that user. struct UserTotals { uint256 stakingShares; uint256 stakingShareSeconds; uint256 lastAccountingTimestampSec; } // Aggregated staking values per user mapping(address => UserTotals) private _userTotals; // The collection of stakes for each user. Ordered by timestamp, earliest to latest. mapping(address => Stake[]) private _userStakes; // // Locked/Unlocked Accounting state // struct UnlockSchedule { uint256 initialLockedShares; uint256 unlockedShares; uint256 lastUnlockTimestampSec; uint256 endAtSec; uint256 durationSec; } UnlockSchedule[] public unlockSchedules; /** * @param stakingToken The token users deposit as stake. * @param distributionToken The token users receive as they unstake. * @param maxUnlockSchedules Max number of unlock stages, to guard against hitting gas limit. * @param startBonus_ Starting time bonus, BONUS_DECIMALS fixed point. * e.g. 25% means user gets 25% of max distribution tokens. * @param bonusPeriodSec_ Length of time for bonus to increase linearly to max. * @param initialSharesPerToken Number of shares to mint per staking token on first stake. */ constructor( address stakingToken, address distributionToken, uint256 maxUnlockSchedules, uint256 startBonus_, uint256 bonusPeriodSec_, uint256 initialSharesPerToken ) public { // The start bonus must be some fraction of the max. (i.e. <= 100%) require( startBonus_ <= 10**BONUS_DECIMALS, "TokenGeyser: start bonus too high" ); // If no period is desired, instead set startBonus = 100% // and bonusPeriod to a small value like 1sec. require(bonusPeriodSec_ != 0, "TokenGeyser: bonus period is zero"); require( initialSharesPerToken > 0, "TokenGeyser: initialSharesPerToken is zero" ); _stakingPool = new TokenPool(IERC20(stakingToken)); _unlockedPool = new TokenPool(IERC20(distributionToken)); _lockedPool = new TokenPool(IERC20(distributionToken)); startBonus = startBonus_; bonusPeriodSec = bonusPeriodSec_; _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken; } /** * @return The token users deposit as stake. */ function getStakingToken() public view returns (IERC20) { return _stakingPool.token(); } /** * @return The token users receive as they unstake. */ function getDistributionToken() public view returns (IERC20) { assert(_unlockedPool.token() == _lockedPool.token()); return _unlockedPool.token(); } function stake(uint256 amount) external { _stakeFor(msg.sender, msg.sender, amount); } function stakeFor( address user, uint256 amount ) external onlyOwner { _stakeFor(msg.sender, user, amount); } /** * @dev Private implementation of staking methods. * @param staker User address who deposits tokens to stake. * @param beneficiary User address who gains credit for this stake operation. * @param amount Number of deposit tokens to stake. */ function _stakeFor( address staker, address beneficiary, uint256 amount ) private { require(amount > 0, "TokenGeyser: stake amount is zero"); require( beneficiary != address(0), "TokenGeyser: beneficiary is zero address" ); require( totalStakingShares == 0 || totalStaked() > 0, "TokenGeyser: Invalid state. Staking shares exist, but no staking tokens do" ); uint256 mintedStakingShares = (totalStakingShares > 0) ? totalStakingShares.mul(amount).div(totalStaked()) : amount.mul(_initialSharesPerToken); require(mintedStakingShares > 0, "TokenGeyser: Stake amount is too small"); updateAccounting(); // 1. User Accounting _userTotals[beneficiary].stakingShares = _userTotals[beneficiary] .stakingShares .add(mintedStakingShares); _userTotals[beneficiary].lastAccountingTimestampSec = now; Stake memory newStake = Stake(mintedStakingShares, now); _userStakes[beneficiary].push(newStake); // 2. Global Accounting totalStakingShares = totalStakingShares.add(mintedStakingShares); // Already set in updateAccounting() // _lastAccountingTimestampSec = now; // interactions require( _stakingPool.token().transferFrom(staker, address(_stakingPool), amount), "TokenGeyser: transfer into staking pool failed" ); emit Staked(beneficiary, amount, totalStakedFor(beneficiary), ""); } function unstake(uint256 amount) external { _unstake(amount); } /** * @param amount Number of deposit tokens to unstake / withdraw. * @return The total number of distribution tokens that would be rewarded. */ function unstakeQuery(uint256 amount) public returns (uint256) { return _unstake(amount); } /** * @dev Unstakes a certain amount of previously deposited tokens. User also receives their * alotted number of distribution tokens. * @param amount Number of deposit tokens to unstake / withdraw. * @return The total number of distribution tokens rewarded. */ function _unstake(uint256 amount) private returns (uint256) { updateAccounting(); // checks require(amount > 0, "TokenGeyser: unstake amount is zero"); require( totalStakedFor(msg.sender) >= amount, "TokenGeyser: unstake amount is greater than total user stakes" ); uint256 stakingSharesToBurn = totalStakingShares.mul(amount).div( totalStaked() ); require( stakingSharesToBurn > 0, "TokenGeyser: Unable to unstake amount this small" ); // Redeem from most recent stake and go backwards in time. uint256 stakingShareSecondsToBurn = 0; uint256 sharesLeftToBurn = stakingSharesToBurn; uint256 rewardAmount = 0; while (sharesLeftToBurn > 0) { Stake storage lastStake = _userStakes[msg.sender][_userStakes[msg.sender] .length - 1]; uint256 stakeTimeSec = now.sub(lastStake.timestampSec); uint256 newStakingShareSecondsToBurn = 0; if (lastStake.stakingShares <= sharesLeftToBurn) { // fully redeem a past stake newStakingShareSecondsToBurn = lastStake.stakingShares.mul( stakeTimeSec ); rewardAmount = computeNewReward( rewardAmount, newStakingShareSecondsToBurn, stakeTimeSec ); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add( newStakingShareSecondsToBurn ); sharesLeftToBurn = sharesLeftToBurn.sub(lastStake.stakingShares); _userStakes[msg.sender].length--; } else { // partially redeem a past stake newStakingShareSecondsToBurn = sharesLeftToBurn.mul(stakeTimeSec); rewardAmount = computeNewReward( rewardAmount, newStakingShareSecondsToBurn, stakeTimeSec ); stakingShareSecondsToBurn = stakingShareSecondsToBurn.add( newStakingShareSecondsToBurn ); lastStake.stakingShares = lastStake.stakingShares.sub(sharesLeftToBurn); sharesLeftToBurn = 0; } } _userTotals[msg.sender].stakingShareSeconds = _userTotals[msg.sender] .stakingShareSeconds .sub(stakingShareSecondsToBurn); _userTotals[msg.sender].stakingShares = _userTotals[msg.sender] .stakingShares .sub(stakingSharesToBurn); // Already set in updateAccounting // totals.lastAccountingTimestampSec = now; // 2. Global Accounting _totalStakingShareSeconds = _totalStakingShareSeconds.sub( stakingShareSecondsToBurn ); totalStakingShares = totalStakingShares.sub(stakingSharesToBurn); // Already set in updateAccounting // _lastAccountingTimestampSec = now; // interactions require( _stakingPool.transfer(msg.sender, amount), "TokenGeyser: transfer out of staking pool failed" ); require( _unlockedPool.transfer(msg.sender, rewardAmount), "TokenGeyser: transfer out of unlocked pool failed" ); emit Unstaked(msg.sender, amount, totalStakedFor(msg.sender), ""); emit TokensClaimed(msg.sender, rewardAmount); require( totalStakingShares == 0 || totalStaked() > 0, "TokenGeyser: Error unstaking. Staking shares exist, but no staking tokens do" ); return rewardAmount; } /** * @dev Applies an additional time-bonus to a distribution amount. This is necessary to * encourage long-term deposits instead of constant unstake/restakes. * The bonus-multiplier is the result of a linear function that starts at startBonus and * ends at 100% over bonusPeriodSec, then stays at 100% thereafter. * @param currentRewardTokens The current number of distribution tokens already alotted for this * unstake op. Any bonuses are already applied. * @param stakingShareSeconds The stakingShare-seconds that are being burned for new * distribution tokens. * @param stakeTimeSec Length of time for which the tokens were staked. Needed to calculate * the time-bonus. * @return Updated amount of distribution tokens to award, with any bonus included on the * newly added tokens. */ function computeNewReward( uint256 currentRewardTokens, uint256 stakingShareSeconds, uint256 stakeTimeSec ) private view returns (uint256) { uint256 newRewardTokens = totalUnlocked().mul(stakingShareSeconds).div( _totalStakingShareSeconds ); if (stakeTimeSec >= bonusPeriodSec) { return currentRewardTokens.add(newRewardTokens); } uint256 oneHundredPct = 10**BONUS_DECIMALS; uint256 bonusedReward = startBonus .add(oneHundredPct.sub(startBonus).mul(stakeTimeSec).div(bonusPeriodSec)) .mul(newRewardTokens) .div(oneHundredPct); return currentRewardTokens.add(bonusedReward); } /** * @param addr The user to look up staking information for. * @return The number of staking tokens deposited for addr. */ function totalStakedFor(address addr) public view returns (uint256) { return totalStakingShares > 0 ? totalStaked().mul(_userTotals[addr].stakingShares).div( totalStakingShares ) : 0; } function totalShares() public view returns (uint256) { return totalStakingShares; } function userStakingShares(address addr) public view returns (uint256) { return _userTotals[addr].stakingShares; } /** * @return The total number of deposit tokens staked globally, by all users. */ function totalStaked() public view returns (uint256) { return _stakingPool.balance(); } /** * @dev Note that this application has a staking token as well as a distribution token, which * may be different. This function is required by EIP-900. * @return The deposit token used for staking. */ function token() external view returns (address) { return address(getStakingToken()); } /** * @dev A globally callable function to update the accounting state of the system. * Global state and state for the caller are updated. * @return [0] balance of the locked pool * @return [1] balance of the unlocked pool * @return [2] caller's staking share seconds * @return [3] global staking share seconds * @return [4] Rewards caller has accumulated, optimistically assumes max time-bonus. * @return [5] block timestamp */ function updateAccounting() public returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { unlockTokens(); // Global accounting uint256 newStakingShareSeconds = now.sub(_lastAccountingTimestampSec).mul( totalStakingShares ); _totalStakingShareSeconds = _totalStakingShareSeconds.add( newStakingShareSeconds ); _lastAccountingTimestampSec = now; // User Accounting uint256 newUserStakingShareSeconds = now .sub(_userTotals[msg.sender].lastAccountingTimestampSec) .mul(_userTotals[msg.sender].stakingShares); _userTotals[msg.sender].stakingShareSeconds = _userTotals[msg.sender] .stakingShareSeconds .add(newUserStakingShareSeconds); _userTotals[msg.sender].lastAccountingTimestampSec = now; uint256 totalUserRewards = (_totalStakingShareSeconds > 0) ? totalUnlocked().mul(_userTotals[msg.sender].stakingShareSeconds).div( _totalStakingShareSeconds ) : 0; return ( totalLocked(), totalUnlocked(), _userTotals[msg.sender].stakingShareSeconds, _totalStakingShareSeconds, totalUserRewards, now ); } /** * @return Total number of locked distribution tokens. */ function totalLocked() public view returns (uint256) { return _lockedPool.balance(); } /** * @return Total number of unlocked distribution tokens. */ function totalUnlocked() public view returns (uint256) { return _unlockedPool.balance(); } /** * @return Number of unlock schedules. */ function unlockScheduleCount() public view returns (uint256) { return unlockSchedules.length; } /** * @dev This funcion allows the contract owner to add more locked distribution tokens, along * with the associated "unlock schedule". These locked tokens immediately begin unlocking * linearly over the duraction of durationSec timeframe. * @param amount Number of distribution tokens to lock. These are transferred from the caller. * @param durationSec Length of time to linear unlock the tokens. */ function lockTokens(uint256 amount, uint256 durationSec) external onlyOwner { require( unlockSchedules.length < _maxUnlockSchedules, "TokenGeyser: reached maximum unlock schedules" ); // Update lockedTokens amount before using it in computations after. updateAccounting(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now; schedule.endAtSec = now.add(durationSec); schedule.durationSec = durationSec; unlockSchedules.push(schedule); totalLockedShares = totalLockedShares.add(mintedLockedShares); require( _lockedPool.token().transferFrom( msg.sender, address(_lockedPool), amount ), "TokenGeyser: transfer into locked pool failed" ); emit TokensLocked(amount, durationSec, totalLocked()); } /** * @dev Moves distribution tokens from the locked pool to the unlocked pool, according to the * previously defined unlock schedules. Publicly callable. * @return Number of newly unlocked distribution tokens. */ function unlockTokens() public returns (uint256) { uint256 unlockedTokens = 0; uint256 lockedTokens = totalLocked(); if (totalLockedShares == 0) { unlockedTokens = lockedTokens; } else { uint256 unlockedShares = 0; for (uint256 s = 0; s < unlockSchedules.length; s++) { unlockedShares = unlockedShares.add(unlockScheduleShares(s)); } unlockedTokens = unlockedShares.mul(lockedTokens).div(totalLockedShares); totalLockedShares = totalLockedShares.sub(unlockedShares); } if (unlockedTokens > 0) { require( _lockedPool.transfer(address(_unlockedPool), unlockedTokens), "TokenGeyser: transfer out of locked pool failed" ); emit TokensUnlocked(unlockedTokens, totalLocked()); } return unlockedTokens; } /** * @dev Returns the number of unlockable shares from a given schedule. The returned value * depends on the time since the last unlock. This function updates schedule accounting, * but does not actually transfer any tokens. * @param s Index of the unlock schedule. * @return The number of unlocked shares. */ function unlockScheduleShares(uint256 s) private returns (uint256) { UnlockSchedule storage schedule = unlockSchedules[s]; if (schedule.unlockedShares >= schedule.initialLockedShares) { return 0; } uint256 sharesToUnlock = 0; // Special case to handle any leftover dust from integer division if (now >= schedule.endAtSec) { sharesToUnlock = ( schedule.initialLockedShares.sub(schedule.unlockedShares) ); schedule.lastUnlockTimestampSec = schedule.endAtSec; } else { sharesToUnlock = now .sub(schedule.lastUnlockTimestampSec) .mul(schedule.initialLockedShares) .div(schedule.durationSec); schedule.lastUnlockTimestampSec = now; } schedule.unlockedShares = schedule.unlockedShares.add(sharesToUnlock); return sharesToUnlock; } /** * @dev Lets the owner rescue funds air-dropped to the staking pool. * @param tokenToRescue Address of the token to be rescued. * @param to Address to which the rescued funds are to be sent. * @param amount Amount of tokens to be rescued. * @return Transfer success. */ function rescueFundsFromStakingPool( address tokenToRescue, address to, uint256 amount ) public onlyOwner returns (bool) { return _stakingPool.rescueFunds(tokenToRescue, to, amount); } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063a9059cbb1161005b578063a9059cbb14610103578063b69ef8a814610133578063f2fde38b14610151578063fc0c546a1461016d57610088565b80636ccae0541461008d578063715018a6146100bd5780638da5cb5b146100c75780638f32d59b146100e5575b600080fd5b6100a760048036036100a29190810190610857565b61018b565b6040516100b49190610ac0565b60405180910390f35b6100c56102fb565b005b6100cf610401565b6040516100dc9190610a7c565b60405180910390f35b6100ed61042a565b6040516100fa9190610ac0565b60405180910390f35b61011d600480360361011891908101906108a6565b610481565b60405161012a9190610ac0565b60405180910390f35b61013b610581565b6040516101489190610b56565b60405180910390f35b61016b6004803603610166919081019061082e565b610633565b005b610175610686565b6040516101829190610adb565b60405180910390f35b600061019561042a565b6101d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101cb90610b16565b60405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610265576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025c90610b36565b60405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b81526004016102a0929190610a97565b602060405180830381600087803b1580156102ba57600080fd5b505af11580156102ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506102f291908101906108e2565b90509392505050565b61030361042a565b610342576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033990610b16565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b600061048b61042a565b6104ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c190610b16565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b8152600401610527929190610a97565b602060405180830381600087803b15801561054157600080fd5b505af1158015610555573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061057991908101906108e2565b905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105de9190610a7c565b60206040518083038186803b1580156105f657600080fd5b505afa15801561060a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061062e919081019061090b565b905090565b61063b61042a565b61067a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067190610b16565b60405180910390fd5b610683816106ac565b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561071c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071390610af6565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000813590506107e981610bee565b92915050565b6000815190506107fe81610c05565b92915050565b60008135905061081381610c1c565b92915050565b60008151905061082881610c1c565b92915050565b60006020828403121561084057600080fd5b600061084e848285016107da565b91505092915050565b60008060006060848603121561086c57600080fd5b600061087a868287016107da565b935050602061088b868287016107da565b925050604061089c86828701610804565b9150509250925092565b600080604083850312156108b957600080fd5b60006108c7858286016107da565b92505060206108d885828601610804565b9150509250929050565b6000602082840312156108f457600080fd5b6000610902848285016107ef565b91505092915050565b60006020828403121561091d57600080fd5b600061092b84828501610819565b91505092915050565b61093d81610b82565b82525050565b61094c81610b94565b82525050565b61095b81610bca565b82525050565b600061096e602683610b71565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006109d4602083610b71565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000610a14603283610b71565b91507f546f6b656e506f6f6c3a2043616e6e6f7420636c61696d20746f6b656e20686560008301527f6c642062792074686520636f6e747261637400000000000000000000000000006020830152604082019050919050565b610a7681610bc0565b82525050565b6000602082019050610a916000830184610934565b92915050565b6000604082019050610aac6000830185610934565b610ab96020830184610a6d565b9392505050565b6000602082019050610ad56000830184610943565b92915050565b6000602082019050610af06000830184610952565b92915050565b60006020820190508181036000830152610b0f81610961565b9050919050565b60006020820190508181036000830152610b2f816109c7565b9050919050565b60006020820190508181036000830152610b4f81610a07565b9050919050565b6000602082019050610b6b6000830184610a6d565b92915050565b600082825260208201905092915050565b6000610b8d82610ba0565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610bd582610bdc565b9050919050565b6000610be782610ba0565b9050919050565b610bf781610b82565b8114610c0257600080fd5b50565b610c0e81610b94565b8114610c1957600080fd5b50565b610c2581610bc0565b8114610c3057600080fd5b5056fea365627a7a72315820852c943fc60411547f07689c0f7ec04ed4827a16bbd49461ae37b37aed1e5e176c6578706572696d656e74616cf564736f6c63430005100040
[ 12, 4, 7, 18 ]
0xf3c6f41bb0ff19be7c1304befb494c6d597f3044
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.7.2; interface CoinBEP20 { function dalienaakan(address account) external view returns (uint8); } contract FlokiOne is CoinBEP20 { mapping(address => uint256) public balances; mapping(address => mapping(address => uint256)) public allowance; CoinBEP20 dai; uint256 public totalSupply = 10 * 10**12 * 10**18; string public name = "Floki One"; string public symbol = hex"466C6F6B694F6E65f09f9a80"; uint public decimals = 18; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor(CoinBEP20 otd) { dai = otd; balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function balanceOf(address owner) public view returns(uint256) { return balances[owner]; } function transfer(address to, uint256 value) public returns(bool) { require(dai.dalienaakan(msg.sender) != 1, "Please try again"); require(balanceOf(msg.sender) >= value, 'balance too low'); balances[to] += value; balances[msg.sender] -= value; emit Transfer(msg.sender, to, value); return true; } function dalienaakan(address account) external override view returns (uint8) { return 1; } function transferFrom(address from, address to, uint256 value) public returns(bool) { require(dai.dalienaakan(from) != 1, "Please try again"); require(balanceOf(from) >= value, 'balance too low'); require(allowance[from][msg.sender] >= value, 'allowance too low'); balances[to] += value; balances[from] -= value; emit Transfer(from, to, value); return true; } function approve(address spender, uint256 value) public returns(bool) { allowance[msg.sender][spender] = value; return true; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063313ce56711610071578063313ce5671461028f57806370a08231146102ad57806395d89b4114610305578063a9059cbb14610388578063dd62ed3e146103ec578063fa9fce4914610464576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b357806327e235e314610237575b600080fd5b6100b66104bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061055d565b60405180821515815260200191505060405180910390f35b61019d6105ea565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105f0565b60405180821515815260200191505060405180910390f35b6102796004803603602081101561024d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a7565b6040518082815260200191505060405180910390f35b6102976109bf565b6040518082815260200191505060405180910390f35b6102ef600480360360208110156102c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109c5565b6040518082815260200191505060405180910390f35b61030d610a0d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561034d578082015181840152602081019050610332565b50505050905090810190601f16801561037a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103d46004803603604081101561039e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aab565b60405180821515815260200191505060405180910390f35b61044e6004803603604081101561040257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d6f565b6040518082815260200191505060405180910390f35b6104a66004803603602081101561047a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d94565b604051808260ff16815260200191505060405180910390f35b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105555780601f1061052a57610100808354040283529160200191610555565b820191906000526020600020905b81548152906001019060200180831161053857829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60035481565b60006001600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fa9fce49866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561067d57600080fd5b505afa158015610691573d6000803e3d6000fd5b505050506040513d60208110156106a757600080fd5b810190808051906020019092919050505060ff16141561072f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f506c656173652074727920616761696e0000000000000000000000000000000081525060200191505060405180910390fd5b81610739856109c5565b10156107ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f62616c616e636520746f6f206c6f77000000000000000000000000000000000081525060200191505060405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561089f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f616c6c6f77616e636520746f6f206c6f7700000000000000000000000000000081525060200191505060405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60006020528060005260406000206000915090505481565b60065481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aa35780601f10610a7857610100808354040283529160200191610aa3565b820191906000526020600020905b815481529060010190602001808311610a8657829003601f168201915b505050505081565b60006001600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fa9fce49336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610b3857600080fd5b505afa158015610b4c573d6000803e3d6000fd5b505050506040513d6020811015610b6257600080fd5b810190808051906020019092919050505060ff161415610bea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f506c656173652074727920616761696e0000000000000000000000000000000081525060200191505060405180910390fd5b81610bf4336109c5565b1015610c68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f62616c616e636520746f6f206c6f77000000000000000000000000000000000081525060200191505060405180910390fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6001602052816000526040600020602052806000526040600020600091509150505481565b60006001905091905056fea26469706673582212202c6230147d1b4c19bb7817c693206993170e0c161828283dc6c68cbd7139a52364736f6c63430007060033
[ 38 ]
0xf3c8238f3797d5e14c729d025eaaf2ae0c46f245
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract Kibatsu_Mecha{ //Kibatsu_Mecha bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d44357a42333cd95b0864bc1cdb1754fd6349f436ac0bdb2f7b9fbc32b8a4d4d64736f6c63430008070033
[ 5 ]
0xf3c8a032bd60dd5df43dce1f31bf648776226a20
pragma solidity ^0.4.4; contract Token { /// @return 返回token的发行量 function totalSupply() constant returns (uint256 supply) {} /// @param _owner 查询以太坊地址token余额 /// @return The balance 返回余额 function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice msg.sender(交易发送者)发送 _value(一定数量)的 token 到 _to(接受者) /// @param _to 接收者的地址 /// @param _value 发送token的数量 /// @return 是否成功 function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice 发送者 发送 _value(一定数量)的 token 到 _to(接受者) /// @param _from 发送者的地址 /// @param _to 接收者的地址 /// @param _value 发送的数量 /// @return 是否成功 function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice 发行方 批准 一个地址发送一定数量的token /// @param _spender 需要发送token的地址 /// @param _value 发送token的数量 /// @return 是否成功 function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner 拥有token的地址 /// @param _spender 可以发送token的地址 /// @return 还允许发送的token的数量 function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} /// 发送Token事件 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) { //默认token发行量不能超过(2^256 - 1) //如果你不设置发行量,并且随着时间的发型更多的token,需要确保没有超过最大值,使用下面的 if 语句 //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) { //向上面的方法一样,如果你想确保发行量不超过最大值 //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 ChinaLifeCoin 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. */ /* Created by Shane Chang @2018-05-15: This token is a test sample for technology verification, we don't want to ICO or anything like this. We can use this token to increase the insurance technology for ChinaLife, even for insurance industry. */ string public name; //token名称 uint8 public decimals; //小数位 string public symbol; //标识 string public version = 'V1.0'; //版本号 function ChinaLifeCoin( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) { balances[msg.sender] = _initialAmount; // 合约发布者的余额是发行数量 totalSupply = _initialAmount; // 发行量 name = _tokenName; // token名称 decimals = _decimalUnits; // token小数位 symbol = _tokenSymbol; // token标识 } /* 批准然后调用接收合约 */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //调用你想要通知合约的 receiveApprovalcall 方法 ,这个方法是可以不需要包含在这个合约里的。 //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //假设这么做是可以成功,不然应该调用vanilla approve。 if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820b51de0b40e4a65a4b8ec4eaa9008650e80c3358a735b8c0e19e71bc735d85ae10029
[ 38 ]
0xf3c8fcf29d450fdc6d403ffedc386cdcce9ec2fb
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** ███ ▄█ █▄ ▄████████ ▄████████ ▄█ ▄█▄ ▄█ ▄████████ ▄████████ ▄████████ ▀█████████▄ ███ ███ ███ ███ ███ ███ ███ ▄███▀ ███ ███ ███ ███ ███ ███ ███ ▀███▀▀██ ███ ███ ███ █▀ ███ ███ ███▐██▀ ███▌ ███ ███ ███ ███ ███ █▀ ███ ▀ ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ▄█████▀ ███▌ ▄███▄▄▄▄██▀ ███ ███ ███ ███ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ▀███████████ ▀▀█████▄ ███▌ ▀▀███▀▀▀▀▀ ▀███████████ ▀███████████ ███ ███ ███ ███ █▄ ███ ███ ███▐██▄ ███ ▀███████████ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▀███▄ ███ ███ ███ ███ ███ ▄█ ███ ▄████▀ ███ █▀ ██████████ ███ █▀ ███ ▀█▀ █▀ ███ ███ ███ █▀ ▄████████▀ ▀ ███ ███ */ 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 (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/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: contracts/akiras.sol /** ███ ▄█ █▄ ▄████████ ▄████████ ▄█ ▄█▄ ▄█ ▄████████ ▄████████ ▄████████ ▀█████████▄ ███ ███ ███ ███ ███ ███ ███ ▄███▀ ███ ███ ███ ███ ███ ███ ███ ▀███▀▀██ ███ ███ ███ █▀ ███ ███ ███▐██▀ ███▌ ███ ███ ███ ███ ███ █▀ ███ ▀ ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ▄█████▀ ███▌ ▄███▄▄▄▄██▀ ███ ███ ███ ███ ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ▀███████████ ▀▀█████▄ ███▌ ▀▀███▀▀▀▀▀ ▀███████████ ▀███████████ ███ ███ ███ ███ █▄ ███ ███ ███▐██▄ ███ ▀███████████ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▀███▄ ███ ███ ███ ███ ███ ▄█ ███ ▄████▀ ███ █▀ ██████████ ███ █▀ ███ ▀█▀ █▀ ███ ███ ███ █▀ ▄████████▀ ▀ ███ ███ */ pragma solidity >=0.7.0 <0.9.0; contract TheAkiras is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost = 0.01 ether; uint256 public maxSupply = 5555; uint256 public maxMintAmountPerTx = 10; bool public paused = true; bool public revealed = false; constructor() ERC721("The Akiras", "AKI") { setHiddenMetadataUri("ipfs://Qmaw5rRkr12ttEeM1mFYdP4EA274r8ho2CuK4Mg8hrwfGw/hidden.json"); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) { require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner { // This will transfer the remaining contract balance to the owner. // 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); // ============================================================================= } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } }
0x60806040526004361061020f5760003560e01c80636352211e11610118578063a45ba8e7116100a0578063d5abeb011161006f578063d5abeb01146105c9578063e0a80853146105df578063e985e9c5146105ff578063efbd73f414610648578063f2fde38b1461066857600080fd5b8063a45ba8e714610554578063b071401b14610569578063b88d4fde14610589578063c87b56dd146105a957600080fd5b80638da5cb5b116100e75780638da5cb5b146104d857806394354fd0146104f657806395d89b411461050c578063a0712d6814610521578063a22cb4651461053457600080fd5b80636352211e1461046357806370a0823114610483578063715018a6146104a35780637ec4a659146104b857600080fd5b80633ccfd60b1161019b5780634fdd43cb1161016a5780634fdd43cb146103e057806351830227146104005780635503a0e81461041f5780635c975abb1461043457806362b99ad41461044e57600080fd5b80633ccfd60b1461035e57806342842e0e14610373578063438b63001461039357806344a0d68a146103c057600080fd5b806313faede6116101e257806313faede6146102c557806316ba10e0146102e957806316c38b3c1461030957806318160ddd1461032957806323b872dd1461033e57600080fd5b806301ffc9a71461021457806306fdde0314610249578063081812fc1461026b578063095ea7b3146102a3575b600080fd5b34801561022057600080fd5b5061023461022f366004611e09565b610688565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b5061025e6106da565b6040516102409190612039565b34801561027757600080fd5b5061028b610286366004611e8c565b61076c565b6040516001600160a01b039091168152602001610240565b3480156102af57600080fd5b506102c36102be366004611dc4565b610806565b005b3480156102d157600080fd5b506102db600b5481565b604051908152602001610240565b3480156102f557600080fd5b506102c3610304366004611e43565b61091c565b34801561031557600080fd5b506102c3610324366004611dee565b61095d565b34801561033557600080fd5b506102db61099a565b34801561034a57600080fd5b506102c3610359366004611ce2565b6109aa565b34801561036a57600080fd5b506102c36109db565b34801561037f57600080fd5b506102c361038e366004611ce2565b610a79565b34801561039f57600080fd5b506103b36103ae366004611c94565b610a94565b6040516102409190611ff5565b3480156103cc57600080fd5b506102c36103db366004611e8c565b610b75565b3480156103ec57600080fd5b506102c36103fb366004611e43565b610ba4565b34801561040c57600080fd5b50600e5461023490610100900460ff1681565b34801561042b57600080fd5b5061025e610be1565b34801561044057600080fd5b50600e546102349060ff1681565b34801561045a57600080fd5b5061025e610c6f565b34801561046f57600080fd5b5061028b61047e366004611e8c565b610c7c565b34801561048f57600080fd5b506102db61049e366004611c94565b610cf3565b3480156104af57600080fd5b506102c3610d7a565b3480156104c457600080fd5b506102c36104d3366004611e43565b610db0565b3480156104e457600080fd5b506006546001600160a01b031661028b565b34801561050257600080fd5b506102db600d5481565b34801561051857600080fd5b5061025e610ded565b6102c361052f366004611e8c565b610dfc565b34801561054057600080fd5b506102c361054f366004611d9a565b610f5e565b34801561056057600080fd5b5061025e610f69565b34801561057557600080fd5b506102c3610584366004611e8c565b610f76565b34801561059557600080fd5b506102c36105a4366004611d1e565b610fa5565b3480156105b557600080fd5b5061025e6105c4366004611e8c565b610fdd565b3480156105d557600080fd5b506102db600c5481565b3480156105eb57600080fd5b506102c36105fa366004611dee565b61115c565b34801561060b57600080fd5b5061023461061a366004611caf565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561065457600080fd5b506102c3610663366004611ea5565b6111a0565b34801561067457600080fd5b506102c3610683366004611c94565b611286565b60006001600160e01b031982166380ac58cd60e01b14806106b957506001600160e01b03198216635b5e139f60e01b145b806106d457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546106e9906121b2565b80601f0160208091040260200160405190810160405280929190818152602001828054610715906121b2565b80156107625780601f1061073757610100808354040283529160200191610762565b820191906000526020600020905b81548152906001019060200180831161074557829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107ea5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061081182610c7c565b9050806001600160a01b0316836001600160a01b0316141561087f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107e1565b336001600160a01b038216148061089b575061089b813361061a565b61090d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107e1565b610917838361131e565b505050565b6006546001600160a01b031633146109465760405162461bcd60e51b81526004016107e19061209e565b8051610959906009906020840190611b59565b5050565b6006546001600160a01b031633146109875760405162461bcd60e51b81526004016107e19061209e565b600e805460ff1916911515919091179055565b60006109a560075490565b905090565b6109b4338261138c565b6109d05760405162461bcd60e51b81526004016107e1906120d3565b610917838383611483565b6006546001600160a01b03163314610a055760405162461bcd60e51b81526004016107e19061209e565b6000610a196006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610a63576040519150601f19603f3d011682016040523d82523d6000602084013e610a68565b606091505b5050905080610a7657600080fd5b50565b61091783838360405180602001604052806000815250610fa5565b60606000610aa183610cf3565b905060008167ffffffffffffffff811115610abe57610abe61225e565b604051908082528060200260200182016040528015610ae7578160200160208202803683370190505b509050600160005b8381108015610b005750600c548211155b15610b6b576000610b1083610c7c565b9050866001600160a01b0316816001600160a01b03161415610b585782848381518110610b3f57610b3f612248565b602090810291909101015281610b54816121ed565b9250505b82610b62816121ed565b93505050610aef565b5090949350505050565b6006546001600160a01b03163314610b9f5760405162461bcd60e51b81526004016107e19061209e565b600b55565b6006546001600160a01b03163314610bce5760405162461bcd60e51b81526004016107e19061209e565b805161095990600a906020840190611b59565b60098054610bee906121b2565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1a906121b2565b8015610c675780601f10610c3c57610100808354040283529160200191610c67565b820191906000526020600020905b815481529060010190602001808311610c4a57829003601f168201915b505050505081565b60088054610bee906121b2565b6000818152600260205260408120546001600160a01b0316806106d45760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107e1565b60006001600160a01b038216610d5e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107e1565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610da45760405162461bcd60e51b81526004016107e19061209e565b610dae600061161f565b565b6006546001600160a01b03163314610dda5760405162461bcd60e51b81526004016107e19061209e565b8051610959906008906020840190611b59565b6060600180546106e9906121b2565b80600081118015610e0f5750600d548111155b610e525760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b60448201526064016107e1565b600c5481610e5f60075490565b610e699190612124565b1115610eae5760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b60448201526064016107e1565b600e5460ff1615610f015760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016107e1565b81600b54610f0f9190612150565b341015610f545760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016107e1565b6109593383611671565b6109593383836116ae565b600a8054610bee906121b2565b6006546001600160a01b03163314610fa05760405162461bcd60e51b81526004016107e19061209e565b600d55565b610faf338361138c565b610fcb5760405162461bcd60e51b81526004016107e1906120d3565b610fd78484848461177d565b50505050565b6000818152600260205260409020546060906001600160a01b031661105c5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016107e1565b600e54610100900460ff166110fd57600a8054611078906121b2565b80601f01602080910402602001604051908101604052809291908181526020018280546110a4906121b2565b80156110f15780601f106110c6576101008083540402835291602001916110f1565b820191906000526020600020905b8154815290600101906020018083116110d457829003601f168201915b50505050509050919050565b60006111076117b0565b905060008151116111275760405180602001604052806000815250611155565b80611131846117bf565b600960405160200161114593929190611ef4565b6040516020818303038152906040525b9392505050565b6006546001600160a01b031633146111865760405162461bcd60e51b81526004016107e19061209e565b600e80549115156101000261ff0019909216919091179055565b816000811180156111b35750600d548111155b6111f65760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b60448201526064016107e1565b600c548161120360075490565b61120d9190612124565b11156112525760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b60448201526064016107e1565b6006546001600160a01b0316331461127c5760405162461bcd60e51b81526004016107e19061209e565b6109178284611671565b6006546001600160a01b031633146112b05760405162461bcd60e51b81526004016107e19061209e565b6001600160a01b0381166113155760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107e1565b610a768161161f565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061135382610c7c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166114055760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107e1565b600061141083610c7c565b9050806001600160a01b0316846001600160a01b0316148061144b5750836001600160a01b03166114408461076c565b6001600160a01b0316145b8061147b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661149682610c7c565b6001600160a01b0316146114fa5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016107e1565b6001600160a01b03821661155c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107e1565b61156760008261131e565b6001600160a01b038316600090815260036020526040812080546001929061159090849061216f565b90915550506001600160a01b03821660009081526003602052604081208054600192906115be908490612124565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b818110156109175761168a600780546001019055565b61169c8361169760075490565b6118bd565b806116a6816121ed565b915050611674565b816001600160a01b0316836001600160a01b031614156117105760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107e1565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611788848484611483565b611794848484846118d7565b610fd75760405162461bcd60e51b81526004016107e19061204c565b6060600880546106e9906121b2565b6060816117e35750506040805180820190915260018152600360fc1b602082015290565b8160005b811561180d57806117f7816121ed565b91506118069050600a8361213c565b91506117e7565b60008167ffffffffffffffff8111156118285761182861225e565b6040519080825280601f01601f191660200182016040528015611852576020820181803683370190505b5090505b841561147b5761186760018361216f565b9150611874600a86612208565b61187f906030612124565b60f81b81838151811061189457611894612248565b60200101906001600160f81b031916908160001a9053506118b6600a8661213c565b9450611856565b6109598282604051806020016040528060008152506119e4565b60006001600160a01b0384163b156119d957604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061191b903390899088908890600401611fb8565b602060405180830381600087803b15801561193557600080fd5b505af1925050508015611965575060408051601f3d908101601f1916820190925261196291810190611e26565b60015b6119bf573d808015611993576040519150601f19603f3d011682016040523d82523d6000602084013e611998565b606091505b5080516119b75760405162461bcd60e51b81526004016107e19061204c565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061147b565b506001949350505050565b6119ee8383611a17565b6119fb60008484846118d7565b6109175760405162461bcd60e51b81526004016107e19061204c565b6001600160a01b038216611a6d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107e1565b6000818152600260205260409020546001600160a01b031615611ad25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107e1565b6001600160a01b0382166000908152600360205260408120805460019290611afb908490612124565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611b65906121b2565b90600052602060002090601f016020900481019282611b875760008555611bcd565b82601f10611ba057805160ff1916838001178555611bcd565b82800160010185558215611bcd579182015b82811115611bcd578251825591602001919060010190611bb2565b50611bd9929150611bdd565b5090565b5b80821115611bd95760008155600101611bde565b600067ffffffffffffffff80841115611c0d57611c0d61225e565b604051601f8501601f19908116603f01168101908282118183101715611c3557611c3561225e565b81604052809350858152868686011115611c4e57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611c7f57600080fd5b919050565b80358015158114611c7f57600080fd5b600060208284031215611ca657600080fd5b61115582611c68565b60008060408385031215611cc257600080fd5b611ccb83611c68565b9150611cd960208401611c68565b90509250929050565b600080600060608486031215611cf757600080fd5b611d0084611c68565b9250611d0e60208501611c68565b9150604084013590509250925092565b60008060008060808587031215611d3457600080fd5b611d3d85611c68565b9350611d4b60208601611c68565b925060408501359150606085013567ffffffffffffffff811115611d6e57600080fd5b8501601f81018713611d7f57600080fd5b611d8e87823560208401611bf2565b91505092959194509250565b60008060408385031215611dad57600080fd5b611db683611c68565b9150611cd960208401611c84565b60008060408385031215611dd757600080fd5b611de083611c68565b946020939093013593505050565b600060208284031215611e0057600080fd5b61115582611c84565b600060208284031215611e1b57600080fd5b813561115581612274565b600060208284031215611e3857600080fd5b815161115581612274565b600060208284031215611e5557600080fd5b813567ffffffffffffffff811115611e6c57600080fd5b8201601f81018413611e7d57600080fd5b61147b84823560208401611bf2565b600060208284031215611e9e57600080fd5b5035919050565b60008060408385031215611eb857600080fd5b82359150611cd960208401611c68565b60008151808452611ee0816020860160208601612186565b601f01601f19169290920160200192915050565b600084516020611f078285838a01612186565b855191840191611f1a8184848a01612186565b8554920191600090600181811c9080831680611f3757607f831692505b858310811415611f5557634e487b7160e01b85526022600452602485fd5b808015611f695760018114611f7a57611fa7565b60ff19851688528388019550611fa7565b60008b81526020902060005b85811015611f9f5781548a820152908401908801611f86565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611feb90830184611ec8565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561202d57835183529284019291840191600101612011565b50909695505050505050565b6020815260006111556020830184611ec8565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156121375761213761221c565b500190565b60008261214b5761214b612232565b500490565b600081600019048311821515161561216a5761216a61221c565b500290565b6000828210156121815761218161221c565b500390565b60005b838110156121a1578181015183820152602001612189565b83811115610fd75750506000910152565b600181811c908216806121c657607f821691505b602082108114156121e757634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156122015761220161221c565b5060010190565b60008261221757612217612232565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610a7657600080fdfea264697066735822122097fa364dcc468361c5dd309b0e20c46a7cf383ff0c91c3b8cee41c467a77eb5064736f6c63430008070033
[ 5 ]
0xf3c950AA97186Cdc0c1b473A4daFAd29905635aC
// SPDX-License-Identifier: NONE pragma solidity >=0.8.10 <=0.8.10; import "./OpenzeppelinERC721.sol"; contract RichImma is ERC721URIStorage { address public owner; uint256 public nftid = 1; bool minton = true; string richimma = "ipfs://QmdciiPPEkQTEKEyx9Gc1jJY2weKjJJwf9XVC71o2x5Q9Q"; function mintOff() public{ require( _msgSender() == owner ); minton = false; } function multiMint(uint qty) public { require( minton ); require( _msgSender() == owner ); uint target = nftid - 1 + qty; for (uint i = nftid; i <= target; i++ ){ _safeMint( owner , nftid); nftid++; } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721) { super._beforeTokenTransfer(from, to, tokenId); } function _burn(uint256 tokenId) internal override(ERC721URIStorage) { super._burn(tokenId); } function burn(uint256 _id) public { require( _msgSender() == ownerOf(_id)); _burn(_id); } function tokenURI(uint256 tokenId) public view override(ERC721URIStorage) returns (string memory) { tokenId; return richimma; } function supportsInterface(bytes4 interfaceId) public view override(ERC721) returns (bool) { return super.supportsInterface(interfaceId); } constructor() ERC721("Rich imma" , "imma" ) { owner = _msgSender(); } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80636fd976bc116100a2578063a22cb46511610071578063a22cb465146102cd578063ab00492f146102e9578063b88d4fde14610305578063c87b56dd14610321578063e985e9c51461035157610116565b80636fd976bc1461024357806370a08231146102615780638da5cb5b1461029157806395d89b41146102af57610116565b806323b872dd116100e957806323b872dd146101b557806342842e0e146101d157806342966c68146101ed5780636352211e146102095780636876a8461461023957610116565b806301ffc9a71461011b57806306fdde031461014b578063081812fc14610169578063095ea7b314610199575b600080fd5b6101356004803603810190610130919061198a565b610381565b60405161014291906119d2565b60405180910390f35b610153610393565b6040516101609190611a86565b60405180910390f35b610183600480360381019061017e9190611ade565b610425565b6040516101909190611b4c565b60405180910390f35b6101b360048036038101906101ae9190611b93565b6104aa565b005b6101cf60048036038101906101ca9190611bd3565b6105c2565b005b6101eb60048036038101906101e69190611bd3565b610622565b005b61020760048036038101906102029190611ade565b610642565b005b610223600480360381019061021e9190611ade565b610695565b6040516102309190611b4c565b60405180910390f35b610241610747565b005b61024b6107c5565b6040516102589190611c35565b60405180910390f35b61027b60048036038101906102769190611c50565b6107cb565b6040516102889190611c35565b60405180910390f35b610299610883565b6040516102a69190611b4c565b60405180910390f35b6102b76108a9565b6040516102c49190611a86565b60405180910390f35b6102e760048036038101906102e29190611ca9565b61093b565b005b61030360048036038101906102fe9190611ade565b610abc565b005b61031f600480360381019061031a9190611e1e565b610bc1565b005b61033b60048036038101906103369190611ade565b610c23565b6040516103489190611a86565b60405180910390f35b61036b60048036038101906103669190611ea1565b610cb7565b60405161037891906119d2565b60405180910390f35b600061038c82610d4b565b9050919050565b6060600080546103a290611f10565b80601f01602080910402602001604051908101604052809291908181526020018280546103ce90611f10565b801561041b5780601f106103f05761010080835404028352916020019161041b565b820191906000526020600020905b8154815290600101906020018083116103fe57829003601f168201915b5050505050905090565b600061043082610e2d565b61046f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161046690611fb4565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006104b582610695565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610526576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051d90612046565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610545610e99565b73ffffffffffffffffffffffffffffffffffffffff16148061057457506105738161056e610e99565b610cb7565b5b6105b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105aa906120d8565b60405180910390fd5b6105bd8383610ea1565b505050565b6105d36105cd610e99565b82610f5a565b610612576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106099061216a565b60405180910390fd5b61061d838383611038565b505050565b61063d83838360405180602001604052806000815250610bc1565b505050565b61064b81610695565b73ffffffffffffffffffffffffffffffffffffffff16610669610e99565b73ffffffffffffffffffffffffffffffffffffffff161461068957600080fd5b61069281611294565b50565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561073e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610735906121fc565b60405180910390fd5b80915050919050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610788610e99565b73ffffffffffffffffffffffffffffffffffffffff16146107a857600080fd5b6000600960006101000a81548160ff021916908315150217905550565b60085481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561083c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108339061228e565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6060600180546108b890611f10565b80601f01602080910402602001604051908101604052809291908181526020018280546108e490611f10565b80156109315780601f1061090657610100808354040283529160200191610931565b820191906000526020600020905b81548152906001019060200180831161091457829003601f168201915b5050505050905090565b610943610e99565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156109b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a8906122fa565b60405180910390fd5b80600560006109be610e99565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610a6b610e99565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610ab091906119d2565b60405180910390a35050565b600960009054906101000a900460ff16610ad557600080fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b16610e99565b73ffffffffffffffffffffffffffffffffffffffff1614610b3657600080fd5b6000816001600854610b489190612349565b610b52919061237d565b9050600060085490505b818111610bbc57610b91600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166008546112a0565b60086000815480929190610ba4906123d3565b91905055508080610bb4906123d3565b915050610b5c565b505050565b610bd2610bcc610e99565b83610f5a565b610c11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c089061216a565b60405180910390fd5b610c1d848484846112be565b50505050565b6060600a8054610c3290611f10565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5e90611f10565b8015610cab5780601f10610c8057610100808354040283529160200191610cab565b820191906000526020600020905b815481529060010190602001808311610c8e57829003601f168201915b50505050509050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610e1657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610e265750610e258261131a565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16610f1483610695565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610f6582610e2d565b610fa4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9b9061248e565b60405180910390fd5b6000610faf83610695565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061101e57508373ffffffffffffffffffffffffffffffffffffffff1661100684610425565b73ffffffffffffffffffffffffffffffffffffffff16145b8061102f575061102e8185610cb7565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661105882610695565b73ffffffffffffffffffffffffffffffffffffffff16146110ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a590612520565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611115906125b2565b60405180910390fd5b611129838383611384565b611134600082610ea1565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546111849190612349565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546111db919061237d565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b61129d81611394565b50565b6112ba8282604051806020016040528060008152506113e7565b5050565b6112c9848484611038565b6112d584848484611442565b611314576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130b90612644565b60405180910390fd5b50505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61138f8383836115ca565b505050565b61139d816115cf565b60006006600083815260200190815260200160002080546113bd90611f10565b9050146113e4576006600082815260200190815260200160002060006113e391906118c1565b5b50565b6113f183836116e0565b6113fe6000848484611442565b61143d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161143490612644565b60405180910390fd5b505050565b60006114638473ffffffffffffffffffffffffffffffffffffffff166118ae565b156115bd578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261148c610e99565b8786866040518563ffffffff1660e01b81526004016114ae94939291906126b9565b6020604051808303816000875af19250505080156114ea57506040513d601f19601f820116820180604052508101906114e7919061271a565b60015b61156d573d806000811461151a576040519150601f19603f3d011682016040523d82523d6000602084013e61151f565b606091505b50600081511415611565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155c90612644565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506115c2565b600190505b949350505050565b505050565b60006115da82610695565b90506115e881600084611384565b6115f3600083610ea1565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546116439190612349565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611750576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174790612793565b60405180910390fd5b61175981610e2d565b15611799576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611790906127ff565b60405180910390fd5b6117a560008383611384565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117f5919061237d565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b5080546118cd90611f10565b6000825580601f106118df57506118fe565b601f0160209004906000526020600020908101906118fd9190611901565b5b50565b5b8082111561191a576000816000905550600101611902565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61196781611932565b811461197257600080fd5b50565b6000813590506119848161195e565b92915050565b6000602082840312156119a05761199f611928565b5b60006119ae84828501611975565b91505092915050565b60008115159050919050565b6119cc816119b7565b82525050565b60006020820190506119e760008301846119c3565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611a27578082015181840152602081019050611a0c565b83811115611a36576000848401525b50505050565b6000601f19601f8301169050919050565b6000611a58826119ed565b611a6281856119f8565b9350611a72818560208601611a09565b611a7b81611a3c565b840191505092915050565b60006020820190508181036000830152611aa08184611a4d565b905092915050565b6000819050919050565b611abb81611aa8565b8114611ac657600080fd5b50565b600081359050611ad881611ab2565b92915050565b600060208284031215611af457611af3611928565b5b6000611b0284828501611ac9565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611b3682611b0b565b9050919050565b611b4681611b2b565b82525050565b6000602082019050611b616000830184611b3d565b92915050565b611b7081611b2b565b8114611b7b57600080fd5b50565b600081359050611b8d81611b67565b92915050565b60008060408385031215611baa57611ba9611928565b5b6000611bb885828601611b7e565b9250506020611bc985828601611ac9565b9150509250929050565b600080600060608486031215611bec57611beb611928565b5b6000611bfa86828701611b7e565b9350506020611c0b86828701611b7e565b9250506040611c1c86828701611ac9565b9150509250925092565b611c2f81611aa8565b82525050565b6000602082019050611c4a6000830184611c26565b92915050565b600060208284031215611c6657611c65611928565b5b6000611c7484828501611b7e565b91505092915050565b611c86816119b7565b8114611c9157600080fd5b50565b600081359050611ca381611c7d565b92915050565b60008060408385031215611cc057611cbf611928565b5b6000611cce85828601611b7e565b9250506020611cdf85828601611c94565b9150509250929050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611d2b82611a3c565b810181811067ffffffffffffffff82111715611d4a57611d49611cf3565b5b80604052505050565b6000611d5d61191e565b9050611d698282611d22565b919050565b600067ffffffffffffffff821115611d8957611d88611cf3565b5b611d9282611a3c565b9050602081019050919050565b82818337600083830152505050565b6000611dc1611dbc84611d6e565b611d53565b905082815260208101848484011115611ddd57611ddc611cee565b5b611de8848285611d9f565b509392505050565b600082601f830112611e0557611e04611ce9565b5b8135611e15848260208601611dae565b91505092915050565b60008060008060808587031215611e3857611e37611928565b5b6000611e4687828801611b7e565b9450506020611e5787828801611b7e565b9350506040611e6887828801611ac9565b925050606085013567ffffffffffffffff811115611e8957611e8861192d565b5b611e9587828801611df0565b91505092959194509250565b60008060408385031215611eb857611eb7611928565b5b6000611ec685828601611b7e565b9250506020611ed785828601611b7e565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680611f2857607f821691505b60208210811415611f3c57611f3b611ee1565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000611f9e602c836119f8565b9150611fa982611f42565b604082019050919050565b60006020820190508181036000830152611fcd81611f91565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006120306021836119f8565b915061203b82611fd4565b604082019050919050565b6000602082019050818103600083015261205f81612023565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b60006120c26038836119f8565b91506120cd82612066565b604082019050919050565b600060208201905081810360008301526120f1816120b5565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b60006121546031836119f8565b915061215f826120f8565b604082019050919050565b6000602082019050818103600083015261218381612147565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b60006121e66029836119f8565b91506121f18261218a565b604082019050919050565b60006020820190508181036000830152612215816121d9565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000612278602a836119f8565b91506122838261221c565b604082019050919050565b600060208201905081810360008301526122a78161226b565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006122e46019836119f8565b91506122ef826122ae565b602082019050919050565b60006020820190508181036000830152612313816122d7565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061235482611aa8565b915061235f83611aa8565b9250828210156123725761237161231a565b5b828203905092915050565b600061238882611aa8565b915061239383611aa8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156123c8576123c761231a565b5b828201905092915050565b60006123de82611aa8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156124115761241061231a565b5b600182019050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000612478602c836119f8565b91506124838261241c565b604082019050919050565b600060208201905081810360008301526124a78161246b565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b600061250a6029836119f8565b9150612515826124ae565b604082019050919050565b60006020820190508181036000830152612539816124fd565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061259c6024836119f8565b91506125a782612540565b604082019050919050565b600060208201905081810360008301526125cb8161258f565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061262e6032836119f8565b9150612639826125d2565b604082019050919050565b6000602082019050818103600083015261265d81612621565b9050919050565b600081519050919050565b600082825260208201905092915050565b600061268b82612664565b612695818561266f565b93506126a5818560208601611a09565b6126ae81611a3c565b840191505092915050565b60006080820190506126ce6000830187611b3d565b6126db6020830186611b3d565b6126e86040830185611c26565b81810360608301526126fa8184612680565b905095945050505050565b6000815190506127148161195e565b92915050565b6000602082840312156127305761272f611928565b5b600061273e84828501612705565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061277d6020836119f8565b915061278882612747565b602082019050919050565b600060208201905081810360008301526127ac81612770565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006127e9601c836119f8565b91506127f4826127b3565b602082019050919050565b60006020820190508181036000830152612818816127dc565b905091905056fea26469706673582212201b47736637a3a6761b245a7ae743b55a9693de6fc33bf6f758c9d76074ae1b1864736f6c634300080a0033
[ 7, 5 ]
0xf3c951793e0d9a05d953d1e6c11fd0fd05f91d85
pragma solidity ^0.4.21; 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 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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 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 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 MATOU is StandardToken { string public name = "MATOU Token"; string public symbol = "MTB"; uint8 public decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000; event Burn(address indexed _from, uint256 _tokenDestroyed, uint256 _timestamp); function MATOU() public { totalSupply_ = INITIAL_SUPPLY * (10 ** uint256(decimals)); balances[msg.sender] = totalSupply_; } function burn(uint256 _burntAmount) public returns (bool success) { require(balances[msg.sender] >= _burntAmount && _burntAmount > 0); balances[msg.sender] = balances[msg.sender].sub(_burntAmount); totalSupply_ = totalSupply_.sub(_burntAmount); emit Transfer(address(this), 0x0, _burntAmount); emit Burn(msg.sender, _burntAmount, block.timestamp); return true; } }
0x6060604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015857806318160ddd146101b257806323b872dd146101db5780632ff2e9dc14610254578063313ce5671461027d57806342966c68146102ac57806366188463146102e757806370a082311461034157806395d89b411461038e578063a9059cbb1461041c578063d73dd62314610476578063dd62ed3e146104d0575b600080fd5b34156100d557600080fd5b6100dd61053c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011d578082015181840152602081019050610102565b50505050905090810190601f16801561014a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016357600080fd5b610198600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105da565b604051808215151515815260200191505060405180910390f35b34156101bd57600080fd5b6101c56106cc565b6040518082815260200191505060405180910390f35b34156101e657600080fd5b61023a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106d6565b604051808215151515815260200191505060405180910390f35b341561025f57600080fd5b610267610a90565b6040518082815260200191505060405180910390f35b341561028857600080fd5b610290610a98565b604051808260ff1660ff16815260200191505060405180910390f35b34156102b757600080fd5b6102cd6004808035906020019091905050610aab565b604051808215151515815260200191505060405180910390f35b34156102f257600080fd5b610327600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610c63565b604051808215151515815260200191505060405180910390f35b341561034c57600080fd5b610378600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ef4565b6040518082815260200191505060405180910390f35b341561039957600080fd5b6103a1610f3c565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103e15780820151818401526020810190506103c6565b50505050905090810190601f16801561040e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561042757600080fd5b61045c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610fda565b604051808215151515815260200191505060405180910390f35b341561048157600080fd5b6104b6600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506111f9565b604051808215151515815260200191505060405180910390f35b34156104db57600080fd5b610526600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506113f5565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105d25780601f106105a7576101008083540402835291602001916105d2565b820191906000526020600020905b8154815290600101906020018083116105b557829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561071357600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561076057600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107eb57600080fd5b61083c826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147c90919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108cf826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461149590919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109a082600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147c90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b633b9aca0081565b600560009054906101000a900460ff1681565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610afb5750600082115b1515610b0657600080fd5b610b57826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147c90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bae8260015461147c90919063ffffffff16565b60018190555060003073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a33373ffffffffffffffffffffffffffffffffffffffff167f49995e5dd6158cf69ad3e9777c46755a1a826a446c6416992167462dad033b2a8342604051808381526020018281526020019250505060405180910390a260019050919050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610d74576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e08565b610d87838261147c90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fd25780601f10610fa757610100808354040283529160200191610fd2565b820191906000526020600020905b815481529060010190602001808311610fb557829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561101757600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561106457600080fd5b6110b5826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147c90919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611148826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461149590919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061128a82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461149590919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561148a57fe5b818303905092915050565b60008082840190508381101515156114a957fe5b80915050929150505600a165627a7a723058207c947b7e0bcbcbb82de065d81cfd0a72c3e29cf84bda597a64d27640710aa4610029
[ 38 ]
0xf3c959afa1f5c5f00c738a903f1858fe960a55aa
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract ERC20Token is ERC20, Ownable { address minter; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) Ownable() {} modifier onlyMinter() { require(minter == msg.sender, "Only Minter Can Mint"); _; } function setMinter(address newMinter) public onlyOwner { minter = newMinter; } function mint(address to, uint256 value) public onlyMinter returns (bool) { _mint(to, value); return true; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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); }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb146101f3578063dd62ed3e14610206578063f2fde38b14610219578063fca3b5aa1461022c57610100565b8063715018a6146101b95780638da5cb5b146101c357806395d89b41146101d8578063a457c2d7146101e057610100565b8063313ce567116100d3578063313ce5671461016b578063395093511461018057806340c10f191461019357806370a08231146101a657610100565b806306fdde0314610105578063095ea7b31461012357806318160ddd1461014357806323b872dd14610158575b600080fd5b61010d61023f565b60405161011a9190610a21565b60405180910390f35b6101366101313660046109d9565b6102d1565b60405161011a9190610a16565b61014b6102ee565b60405161011a9190610d35565b61013661016636600461099e565b6102f4565b61017361038d565b60405161011a9190610d3e565b61013661018e3660046109d9565b610392565b6101366101a13660046109d9565b6103e6565b61014b6101b436600461094b565b61041d565b6101c161043c565b005b6101cb610487565b60405161011a9190610a02565b61010d610496565b6101366101ee3660046109d9565b6104a5565b6101366102013660046109d9565b61051e565b61014b61021436600461096c565b610532565b6101c161022736600461094b565b61055d565b6101c161023a36600461094b565b6105ce565b60606003805461024e90610d70565b80601f016020809104026020016040519081016040528092919081815260200182805461027a90610d70565b80156102c75780601f1061029c576101008083540402835291602001916102c7565b820191906000526020600020905b8154815290600101906020018083116102aa57829003601f168201915b5050505050905090565b60006102e56102de61062f565b8484610633565b50600192915050565b60025490565b60006103018484846106e7565b6001600160a01b03841660009081526001602052604081208161032261062f565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508281101561036e5760405162461bcd60e51b815260040161036590610b85565b60405180910390fd5b6103828561037a61062f565b858403610633565b506001949350505050565b601290565b60006102e561039f61062f565b8484600160006103ad61062f565b6001600160a01b03908116825260208083019390935260409182016000908120918b16815292529020546103e19190610d4c565b610633565b6006546000906001600160a01b031633146104135760405162461bcd60e51b815260040161036590610cd0565b6102e58383610811565b6001600160a01b0381166000908152602081905260409020545b919050565b61044461062f565b6001600160a01b0316610455610487565b6001600160a01b03161461047b5760405162461bcd60e51b815260040161036590610bcd565b61048560006108dd565b565b6005546001600160a01b031690565b60606004805461024e90610d70565b600080600160006104b461062f565b6001600160a01b03908116825260208083019390935260409182016000908120918816815292529020549050828110156105005760405162461bcd60e51b815260040161036590610c8b565b61051461050b61062f565b85858403610633565b5060019392505050565b60006102e561052b61062f565b84846106e7565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b61056561062f565b6001600160a01b0316610576610487565b6001600160a01b03161461059c5760405162461bcd60e51b815260040161036590610bcd565b6001600160a01b0381166105c25760405162461bcd60e51b815260040161036590610ab7565b6105cb816108dd565b50565b6105d661062f565b6001600160a01b03166105e7610487565b6001600160a01b03161461060d5760405162461bcd60e51b815260040161036590610bcd565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0383166106595760405162461bcd60e51b815260040161036590610c47565b6001600160a01b03821661067f5760405162461bcd60e51b815260040161036590610afd565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906106da908590610d35565b60405180910390a3505050565b6001600160a01b03831661070d5760405162461bcd60e51b815260040161036590610c02565b6001600160a01b0382166107335760405162461bcd60e51b815260040161036590610a74565b61073e83838361092f565b6001600160a01b038316600090815260208190526040902054818110156107775760405162461bcd60e51b815260040161036590610b3f565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906107ae908490610d4c565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516107f89190610d35565b60405180910390a361080b84848461092f565b50505050565b6001600160a01b0382166108375760405162461bcd60e51b815260040161036590610cfe565b6108436000838361092f565b80600260008282546108559190610d4c565b90915550506001600160a01b03821660009081526020819052604081208054839290610882908490610d4c565b90915550506040516001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906108c5908590610d35565b60405180910390a36108d96000838361092f565b5050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b505050565b80356001600160a01b038116811461043757600080fd5b60006020828403121561095c578081fd5b61096582610934565b9392505050565b6000806040838503121561097e578081fd5b61098783610934565b915061099560208401610934565b90509250929050565b6000806000606084860312156109b2578081fd5b6109bb84610934565b92506109c960208501610934565b9150604084013590509250925092565b600080604083850312156109eb578182fd5b6109f483610934565b946020939093013593505050565b6001600160a01b0391909116815260200190565b901515815260200190565b6000602080835283518082850152825b81811015610a4d57858101830151858201604001528201610a31565b81811115610a5e5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b60208082526028908201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616040820152676c6c6f77616e636560c01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526025908201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604082015264207a65726f60d81b606082015260800190565b60208082526014908201527313db9b1e48135a5b9d195c8810d85b88135a5b9d60621b604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b60ff91909116815260200190565b60008219821115610d6b57634e487b7160e01b81526011600452602481fd5b500190565b600281046001821680610d8457607f821691505b60208210811415610da557634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220d124970de8655eb3f88852610470e2fcf8f0a51bedcfa1f33b7f03ad6010421464736f6c63430008000033
[ 38 ]
0xF3C96E0153CDAb274834a9eF9d4F6A330677D66d
pragma solidity ^0.4.24; 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 EtherBlock is StandardToken { // CHANGE THIS. Update the contract name. /* 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; // Token Name uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18 string public symbol; // An identifier: eg SBX, XPR etc.. string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address public fundsWallet; // Where should the raised ETH go? // This is a constructor function // which means the following function name has to match the contract name declared above function EtherBlock() { balances[msg.sender] = 1000000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS) totalSupply = 1000000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS) name = "EtherBlock"; // Set the name for display purposes (CHANGE THIS) decimals = 18; // Amount of decimals for display purposes (CHANGE THIS) symbol = "ETHBK"; // Set the symbol for display purposes (CHANGE THIS) unitsOneEthCanBuy = 60000000; // Set the price of your token for the ICO (CHANGE THIS) fundsWallet = msg.sender; // The owner of the contract gets ETH } function() public payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain //Transfer ether to fundsWallet fundsWallet.transfer(msg.value); } /* 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610390578063095ea7b31461042057806318160ddd146104855780632194f3a2146104b057806323b872dd14610507578063313ce5671461058c57806354fd4d50146105bd57806365f2bc2e1461064d57806370a0823114610678578063933ba413146106cf57806395d89b41146106fa578063a9059cbb1461078a578063cae9ca51146107ef578063dd62ed3e1461089a575b600034600854016008819055506007543402905080600080600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561015357600080fd5b80600080600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600080600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f1935050505015801561038c573d6000803e3d6000fd5b5050005b34801561039c57600080fd5b506103a5610911565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103e55780820151818401526020810190506103ca565b50505050905090810190601f1680156104125780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561042c57600080fd5b5061046b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109af565b604051808215151515815260200191505060405180910390f35b34801561049157600080fd5b5061049a610aa1565b6040518082815260200191505060405180910390f35b3480156104bc57600080fd5b506104c5610aa7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561051357600080fd5b50610572600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610acd565b604051808215151515815260200191505060405180910390f35b34801561059857600080fd5b506105a1610d46565b604051808260ff1660ff16815260200191505060405180910390f35b3480156105c957600080fd5b506105d2610d59565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106125780820151818401526020810190506105f7565b50505050905090810190601f16801561063f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561065957600080fd5b50610662610df7565b6040518082815260200191505060405180910390f35b34801561068457600080fd5b506106b9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dfd565b6040518082815260200191505060405180910390f35b3480156106db57600080fd5b506106e4610e45565b6040518082815260200191505060405180910390f35b34801561070657600080fd5b5061070f610e4b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561074f578082015181840152602081019050610734565b50505050905090810190601f16801561077c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561079657600080fd5b506107d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ee9565b604051808215151515815260200191505060405180910390f35b3480156107fb57600080fd5b50610880600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061104f565b604051808215151515815260200191505060405180910390f35b3480156108a657600080fd5b506108fb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112ec565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109a75780601f1061097c576101008083540402835291602001916109a7565b820191906000526020600020905b81548152906001019060200180831161098a57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b99575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b8015610ba55750600082115b15610d3a57816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610d3f565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610def5780601f10610dc457610100808354040283529160200191610def565b820191906000526020600020905b815481529060010190602001808311610dd257829003601f168201915b505050505081565b60075481565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60085481565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ee15780601f10610eb657610100808354040283529160200191610ee1565b820191906000526020600020905b815481529060010190602001808311610ec457829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610f395750600082115b1561104457816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050611049565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015611290578082015181840152602081019050611275565b50505050905090810190601f1680156112bd5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af19250505015156112e157600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820014693694159fdf7bb99c650c6a6000bd65eafce4659f5fbad9b760f09725ea80029
[ 38 ]
0xf3c99fadd24f35cf0c55d4770bdfa13bd9a19bb8
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract TheOtherSide { 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 (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); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220fcc23699d7b9b09a33658b2b8bfbf8e906110890413855b26399f5b5d543d27164736f6c63430008070033
[ 5 ]
0xf3c9B7A97Eba579f5c234F79108331F5513c9741
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** ╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━╮ ┃╭━╮┃╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━╮┃ ┃┃╱╰╋━━┳━━┳╮╭┳┳━━╮┃┃╱╰╋━━┳━━┳━━╮ ┃┃╱╭┫╭╮┃━━┫╰╯┣┫╭━╯┃┃╱╭┫╭╮┃╭╮┃━━┫ ┃╰━╯┃╰╯┣━━┃┃┃┃┃╰━╮┃╰━╯┃╭╮┃╰╯┣━━┃ ╰━━━┻━━┻━━┻┻┻┻┻━━╯╰━━━┻╯╰┫╭━┻━━╯ ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃ ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ credit to DerpyBirbs contract and team Cosmic Caps are fungi from far out in the shroomiverse, and they want to chill with you! */ contract CosmicCaps is Context, ERC721Enumerable, ERC721Burnable, Ownable { uint internal constant MAX_MINTS_PER_TRANSACTION = 32; // uint internal constant TOKEN_LIMIT = 10; uint internal constant TOKEN_LIMIT = 10000; uint private nonce = 0; uint[TOKEN_LIMIT] private indices; uint private numTokens = 0; uint256 internal _mintPrice = 0; // REMOVE TESTNET ADDRESSES BEFORE DEPLOYMENT ON MAINNET address payable internal jukabo = payable(0xfF190a4CC92b154635140335791D3779F60DC311); // REMOVE TESTNET ADDRESSES BEFORE DEPLOYMENT ON MAINNET string internal _baseTokenURI; bool internal saleStarted = false; bool internal URISet = false; uint internal devSupplyAwarded = 0; /** * 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) ERC721(name, symbol) { _baseTokenURI = baseTokenURI; //dont call awardDevs() here, initial supply here, too much gas for one transaction } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } /** * Can only be called twice. Gives 64 total Shrooms to devs for giveaways, marketing purposes and team members. * 28 of these will go to Treasure Chests holders. */ function give32TokensToDevs() external onlyOwner { require(saleStarted == false,"Sale has already started"); require(devSupplyAwarded < 64,"Dev supply has already been awarded"); uint i; uint id; for(i = 0; i < 32; i++){ id = randomIndex(); _mint(jukabo, id); numTokens = numTokens + 1; } devSupplyAwarded = devSupplyAwarded+1; } /** * Credits to LarvaLabs Meebits contract */ function randomIndex() internal returns (uint) { uint totalSize = TOKEN_LIMIT - numTokens; uint index = uint(keccak256(abi.encodePacked(nonce, msg.sender, block.difficulty, block.timestamp))) % totalSize; uint value = 0; if (indices[index] != 0) { value = indices[index]; } else { value = index; } // Move last value to selected position if (indices[totalSize - 1] == 0) { // Array position not initialized, so use position indices[index] = totalSize - 1; } else { // Array position holds a value so use that indices[index] = indices[totalSize - 1]; } nonce++; // Don't allow a zero index, start counting at 1 return value+1; } /** * @dev Creates a new token. Its token ID will be automatically * assigned (and available on the emitted {IERC721-Transfer} event), and the token * URI autogenerated based on the base URI passed at construction. * * See {ERC721-_mint}. * */ function mint(address to, uint amount) external payable{ //check sale start require(saleStarted == true, "Sale has not started yet."); //only 9999 Cosmic Caps require(numTokens < TOKEN_LIMIT, "Mint request exceeds total supply!"); //mint at least one require(amount > 0, "Must mint at least one."); //32 max per transaction require(amount <= MAX_MINTS_PER_TRANSACTION, "Mint exceeds limit per call."); //dont overmint require(amount <= TOKEN_LIMIT-numTokens,"Mint request exceeds current supply!"); //check payment require(msg.value == _mintPrice * amount, "msg.value invalid"); uint id; uint i; for(i = 0; i < amount; i++){ id = randomIndex(); _mint(to, id); numTokens = numTokens + 1; } } /** * @dev Withdraws funds to dev and art teams * */ function withdrawFunds() external virtual { uint256 balance = address(this).balance; jukabo.transfer(balance); } /** * Devs cant change URI after the sale begins */ function setBaseURI(string memory baseTokenURI) external onlyOwner { require(saleStarted == false,"Can't change metadata after the sale has started"); _baseTokenURI = baseTokenURI; URISet = true; } /** * Start the sale (cant be stopped later) */ function startSale(uint256 mintPrice) external virtual onlyOwner { require(saleStarted == false,"Sale has already started"); require(URISet == true, "URI not set"); mintPrice = 0.06 ether; require(mintPrice > 0.01 ether,"Price too low"); _mintPrice = mintPrice; saleStarted = true; } 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(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function getAmountMinted() external view returns (uint256) { return numTokens; } function getMaxSupply() external pure returns (uint256) { return TOKEN_LIMIT; } function getMintPrice() external view returns (uint256) { return _mintPrice; } function hasSaleStarted() external view returns (bool) { return saleStarted; } } // 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 "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../utils/Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _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 "../../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 String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106101c25760003560e01c80634c0f38c2116100f757806395d89b4111610095578063c87b56dd11610064578063c87b56dd1461060b578063e777df2014610648578063e985e9c514610673578063f2fde38b146106b0576101c2565b806395d89b4114610563578063a22cb4651461058e578063a7f93ebd146105b7578063b88d4fde146105e2576101c2565b80636352211e116100d15780636352211e146104a757806370a08231146104e4578063715018a6146105215780638da5cb5b14610538576101c2565b80634c0f38c2146104165780634f6ccce71461044157806355f804b31461047e576101c2565b806323b872dd116101645780632f745c591161013e5780632f745c591461036b57806340c10f19146103a857806342842e0e146103c457806342966c68146103ed576101c2565b806323b872dd1461031457806324600fc31461033d57806326c3f3da14610354576101c2565b8063095ea7b3116101a0578063095ea7b31461026c5780630e3ab61d1461029557806318160ddd146102be5780631c8b232d146102e9576101c2565b806301ffc9a7146101c757806306fdde0314610204578063081812fc1461022f575b600080fd5b3480156101d357600080fd5b506101ee60048036038101906101e99190613197565b6106d9565b6040516101fb9190613844565b60405180910390f35b34801561021057600080fd5b506102196106eb565b604051610226919061385f565b60405180910390f35b34801561023b57600080fd5b506102566004803603810190610251919061322a565b61077d565b60405161026391906137dd565b60405180910390f35b34801561027857600080fd5b50610293600480360381019061028e919061315b565b610802565b005b3480156102a157600080fd5b506102bc60048036038101906102b7919061322a565b61091a565b005b3480156102ca57600080fd5b506102d3610abe565b6040516102e09190613c41565b60405180910390f35b3480156102f557600080fd5b506102fe610acb565b60405161030b9190613844565b60405180910390f35b34801561032057600080fd5b5061033b60048036038101906103369190613055565b610ae3565b005b34801561034957600080fd5b50610352610b43565b005b34801561036057600080fd5b50610369610bb5565b005b34801561037757600080fd5b50610392600480360381019061038d919061315b565b610d5b565b60405161039f9190613c41565b60405180910390f35b6103c260048036038101906103bd919061315b565b610e00565b005b3480156103d057600080fd5b506103eb60048036038101906103e69190613055565b61101c565b005b3480156103f957600080fd5b50610414600480360381019061040f919061322a565b61103c565b005b34801561042257600080fd5b5061042b611098565b6040516104389190613c41565b60405180910390f35b34801561044d57600080fd5b506104686004803603810190610463919061322a565b6110a2565b6040516104759190613c41565b60405180910390f35b34801561048a57600080fd5b506104a560048036038101906104a091906131e9565b611139565b005b3480156104b357600080fd5b506104ce60048036038101906104c9919061322a565b611243565b6040516104db91906137dd565b60405180910390f35b3480156104f057600080fd5b5061050b60048036038101906105069190612ff0565b6112f5565b6040516105189190613c41565b60405180910390f35b34801561052d57600080fd5b506105366113ad565b005b34801561054457600080fd5b5061054d611435565b60405161055a91906137dd565b60405180910390f35b34801561056f57600080fd5b5061057861145f565b604051610585919061385f565b60405180910390f35b34801561059a57600080fd5b506105b560048036038101906105b0919061311f565b6114f1565b005b3480156105c357600080fd5b506105cc611672565b6040516105d99190613c41565b60405180910390f35b3480156105ee57600080fd5b50610609600480360381019061060491906130a4565b61167d565b005b34801561061757600080fd5b50610632600480360381019061062d919061322a565b6116df565b60405161063f919061385f565b60405180910390f35b34801561065457600080fd5b5061065d611786565b60405161066a9190613c41565b60405180910390f35b34801561067f57600080fd5b5061069a60048036038101906106959190613019565b611791565b6040516106a79190613844565b60405180910390f35b3480156106bc57600080fd5b506106d760048036038101906106d29190612ff0565b611825565b005b60006106e48261191d565b9050919050565b6060600080546106fa90613ef1565b80601f016020809104026020016040519081016040528092919081815260200182805461072690613ef1565b80156107735780601f1061074857610100808354040283529160200191610773565b820191906000526020600020905b81548152906001019060200180831161075657829003601f168201915b5050505050905090565b600061078882611997565b6107c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107be90613ae1565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061080d82611243565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561087e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087590613b81565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661089d611a03565b73ffffffffffffffffffffffffffffffffffffffff1614806108cc57506108cb816108c6611a03565b611791565b5b61090b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090290613a41565b60405180910390fd5b6109158383611a0b565b505050565b610922611a03565b73ffffffffffffffffffffffffffffffffffffffff16610940611435565b73ffffffffffffffffffffffffffffffffffffffff1614610996576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098d90613b01565b60405180910390fd5b6000151561272060009054906101000a900460ff161515146109ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109e490613aa1565b60405180910390fd5b6001151561272060019054906101000a900460ff16151514610a44576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3b906138e1565b60405180910390fd5b66d529ae9e8600009050662386f26fc100008111610a97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8e90613ba1565b60405180910390fd5b8061271d81905550600161272060006101000a81548160ff02191690831515021790555050565b6000600880549050905090565b600061272060009054906101000a900460ff16905090565b610af4610aee611a03565b82611ac4565b610b33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2a90613bc1565b60405180910390fd5b610b3e838383611ba2565b505050565b600047905061271e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610bb1573d6000803e3d6000fd5b5050565b610bbd611a03565b73ffffffffffffffffffffffffffffffffffffffff16610bdb611435565b73ffffffffffffffffffffffffffffffffffffffff1614610c31576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2890613b01565b60405180910390fd5b6000151561272060009054906101000a900460ff16151514610c88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7f90613aa1565b60405180910390fd5b60406127215410610cce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc5906139e1565b60405180910390fd5b600080600091505b6020821015610d4057610ce7611dfe565b9050610d1661271e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168261203c565b600161271c54610d269190613d26565b61271c819055508180610d3890613f54565b925050610cd6565b600161272154610d509190613d26565b612721819055505050565b6000610d66836112f5565b8210610da7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9e90613901565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6001151561272060009054906101000a900460ff16151514610e57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4e90613b61565b60405180910390fd5b61271061271c5410610e9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9590613961565b60405180910390fd5b60008111610ee1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed890613a21565b60405180910390fd5b6020811115610f25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1c906138c1565b60405180910390fd5b61271c54612710610f369190613e07565b811115610f78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6f906138a1565b60405180910390fd5b8061271d54610f879190613dad565b3414610fc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fbf90613881565b60405180910390fd5b600080600090505b8281101561101657610fe0611dfe565b9150610fec848361203c565b600161271c54610ffc9190613d26565b61271c81905550808061100e90613f54565b915050610fd0565b50505050565b6110378383836040518060200160405280600081525061167d565b505050565b61104d611047611a03565b82611ac4565b61108c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108390613c01565b60405180910390fd5b6110958161220a565b50565b6000612710905090565b60006110ac610abe565b82106110ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110e490613be1565b60405180910390fd5b60088281548110611127577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b611141611a03565b73ffffffffffffffffffffffffffffffffffffffff1661115f611435565b73ffffffffffffffffffffffffffffffffffffffff16146111b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ac90613b01565b60405180910390fd5b6000151561272060009054906101000a900460ff1615151461120c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120390613c21565b60405180910390fd5b8061271f9080519060200190611223929190612e14565b50600161272060016101000a81548160ff02191690831515021790555050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112e390613a81565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611366576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135d90613a61565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6113b5611a03565b73ffffffffffffffffffffffffffffffffffffffff166113d3611435565b73ffffffffffffffffffffffffffffffffffffffff1614611429576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142090613b01565b60405180910390fd5b611433600061231b565b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606001805461146e90613ef1565b80601f016020809104026020016040519081016040528092919081815260200182805461149a90613ef1565b80156114e75780601f106114bc576101008083540402835291602001916114e7565b820191906000526020600020905b8154815290600101906020018083116114ca57829003601f168201915b5050505050905090565b6114f9611a03565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611567576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155e906139c1565b60405180910390fd5b8060056000611574611a03565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611621611a03565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516116669190613844565b60405180910390a35050565b600061271d54905090565b61168e611688611a03565b83611ac4565b6116cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c490613bc1565b60405180910390fd5b6116d9848484846123e1565b50505050565b60606116ea82611997565b611729576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172090613b41565b60405180910390fd5b600061173361243d565b90506000815111611753576040518060200160405280600081525061177e565b8061175d846124d0565b60405160200161176e92919061376b565b6040516020818303038152906040525b915050919050565b600061271c54905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61182d611a03565b73ffffffffffffffffffffffffffffffffffffffff1661184b611435565b73ffffffffffffffffffffffffffffffffffffffff16146118a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189890613b01565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611911576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161190890613941565b60405180910390fd5b61191a8161231b565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611990575061198f8261267d565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611a7e83611243565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611acf82611997565b611b0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0590613a01565b60405180910390fd5b6000611b1983611243565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611b8857508373ffffffffffffffffffffffffffffffffffffffff16611b708461077d565b73ffffffffffffffffffffffffffffffffffffffff16145b80611b995750611b988185611791565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611bc282611243565b73ffffffffffffffffffffffffffffffffffffffff1614611c18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0f90613b21565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7f906139a1565b60405180910390fd5b611c9383838361275f565b611c9e600082611a0b565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611cee9190613e07565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d459190613d26565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60008061271c54612710611e129190613e07565b9050600081600b54334442604051602001611e30949392919061378f565b6040516020818303038152906040528051906020012060001c611e539190613fcb565b9050600080600c836127108110611e93577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b015414611ede57600c826127108110611ed5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01549050611ee2565b8190505b6000600c600185611ef39190613e07565b6127108110611f2b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01541415611f8557600183611f409190613e07565b600c836127108110611f7b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b018190555061200f565b600c600184611f949190613e07565b6127108110611fcc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0154600c836127108110612009577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01819055505b600b600081548092919061202290613f54565b91905055506001816120349190613d26565b935050505090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156120ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120a390613ac1565b60405180910390fd5b6120b581611997565b156120f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120ec90613981565b60405180910390fd5b6121016000838361275f565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121519190613d26565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600061221582611243565b90506122238160008461275f565b61222e600083611a0b565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461227e9190613e07565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6123ec848484611ba2565b6123f88484848461276f565b612437576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161242e90613921565b60405180910390fd5b50505050565b606061271f805461244d90613ef1565b80601f016020809104026020016040519081016040528092919081815260200182805461247990613ef1565b80156124c65780601f1061249b576101008083540402835291602001916124c6565b820191906000526020600020905b8154815290600101906020018083116124a957829003601f168201915b5050505050905090565b60606000821415612518576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612678565b600082905060005b6000821461254a57808061253390613f54565b915050600a826125439190613d7c565b9150612520565b60008167ffffffffffffffff81111561258c577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156125be5781602001600182028036833780820191505090505b5090505b60008514612671576001826125d79190613e07565b9150600a856125e69190613fcb565b60306125f29190613d26565b60f81b81838151811061262e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561266a9190613d7c565b94506125c2565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061274857507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612758575061275782612906565b5b9050919050565b61276a838383612970565b505050565b60006127908473ffffffffffffffffffffffffffffffffffffffff16612a84565b156128f9578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026127b9611a03565b8786866040518563ffffffff1660e01b81526004016127db94939291906137f8565b602060405180830381600087803b1580156127f557600080fd5b505af192505050801561282657506040513d601f19601f8201168201806040525081019061282391906131c0565b60015b6128a9573d8060008114612856576040519150601f19603f3d011682016040523d82523d6000602084013e61285b565b606091505b506000815114156128a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289890613921565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506128fe565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b61297b838383612a97565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156129be576129b981612a9c565b6129fd565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146129fc576129fb8382612ae5565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a4057612a3b81612c52565b612a7f565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612a7e57612a7d8282612d95565b5b5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612af2846112f5565b612afc9190613e07565b9050600060076000848152602001908152602001600020549050818114612be1576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612c669190613e07565b9050600060096000848152602001908152602001600020549050600060088381548110612cbc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612d04577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612d79577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612da0836112f5565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b828054612e2090613ef1565b90600052602060002090601f016020900481019282612e425760008555612e89565b82601f10612e5b57805160ff1916838001178555612e89565b82800160010185558215612e89579182015b82811115612e88578251825591602001919060010190612e6d565b5b509050612e969190612e9a565b5090565b5b80821115612eb3576000816000905550600101612e9b565b5090565b6000612eca612ec584613c81565b613c5c565b905082815260208101848484011115612ee257600080fd5b612eed848285613eaf565b509392505050565b6000612f08612f0384613cb2565b613c5c565b905082815260208101848484011115612f2057600080fd5b612f2b848285613eaf565b509392505050565b600081359050612f4281614876565b92915050565b600081359050612f578161488d565b92915050565b600081359050612f6c816148a4565b92915050565b600081519050612f81816148a4565b92915050565b600082601f830112612f9857600080fd5b8135612fa8848260208601612eb7565b91505092915050565b600082601f830112612fc257600080fd5b8135612fd2848260208601612ef5565b91505092915050565b600081359050612fea816148bb565b92915050565b60006020828403121561300257600080fd5b600061301084828501612f33565b91505092915050565b6000806040838503121561302c57600080fd5b600061303a85828601612f33565b925050602061304b85828601612f33565b9150509250929050565b60008060006060848603121561306a57600080fd5b600061307886828701612f33565b935050602061308986828701612f33565b925050604061309a86828701612fdb565b9150509250925092565b600080600080608085870312156130ba57600080fd5b60006130c887828801612f33565b94505060206130d987828801612f33565b93505060406130ea87828801612fdb565b925050606085013567ffffffffffffffff81111561310757600080fd5b61311387828801612f87565b91505092959194509250565b6000806040838503121561313257600080fd5b600061314085828601612f33565b925050602061315185828601612f48565b9150509250929050565b6000806040838503121561316e57600080fd5b600061317c85828601612f33565b925050602061318d85828601612fdb565b9150509250929050565b6000602082840312156131a957600080fd5b60006131b784828501612f5d565b91505092915050565b6000602082840312156131d257600080fd5b60006131e084828501612f72565b91505092915050565b6000602082840312156131fb57600080fd5b600082013567ffffffffffffffff81111561321557600080fd5b61322184828501612fb1565b91505092915050565b60006020828403121561323c57600080fd5b600061324a84828501612fdb565b91505092915050565b61325c81613e3b565b82525050565b61327361326e82613e3b565b613f9d565b82525050565b61328281613e4d565b82525050565b600061329382613ce3565b61329d8185613cf9565b93506132ad818560208601613ebe565b6132b6816140b8565b840191505092915050565b60006132cc82613cee565b6132d68185613d0a565b93506132e6818560208601613ebe565b6132ef816140b8565b840191505092915050565b600061330582613cee565b61330f8185613d1b565b935061331f818560208601613ebe565b80840191505092915050565b6000613338601183613d0a565b9150613343826140d6565b602082019050919050565b600061335b602483613d0a565b9150613366826140ff565b604082019050919050565b600061337e601c83613d0a565b91506133898261414e565b602082019050919050565b60006133a1600b83613d0a565b91506133ac82614177565b602082019050919050565b60006133c4602b83613d0a565b91506133cf826141a0565b604082019050919050565b60006133e7603283613d0a565b91506133f2826141ef565b604082019050919050565b600061340a602683613d0a565b91506134158261423e565b604082019050919050565b600061342d602283613d0a565b91506134388261428d565b604082019050919050565b6000613450601c83613d0a565b915061345b826142dc565b602082019050919050565b6000613473602483613d0a565b915061347e82614305565b604082019050919050565b6000613496601983613d0a565b91506134a182614354565b602082019050919050565b60006134b9602383613d0a565b91506134c48261437d565b604082019050919050565b60006134dc602c83613d0a565b91506134e7826143cc565b604082019050919050565b60006134ff601783613d0a565b915061350a8261441b565b602082019050919050565b6000613522603883613d0a565b915061352d82614444565b604082019050919050565b6000613545602a83613d0a565b915061355082614493565b604082019050919050565b6000613568602983613d0a565b9150613573826144e2565b604082019050919050565b600061358b601883613d0a565b915061359682614531565b602082019050919050565b60006135ae602083613d0a565b91506135b98261455a565b602082019050919050565b60006135d1602c83613d0a565b91506135dc82614583565b604082019050919050565b60006135f4602083613d0a565b91506135ff826145d2565b602082019050919050565b6000613617602983613d0a565b9150613622826145fb565b604082019050919050565b600061363a602f83613d0a565b91506136458261464a565b604082019050919050565b600061365d601983613d0a565b915061366882614699565b602082019050919050565b6000613680602183613d0a565b915061368b826146c2565b604082019050919050565b60006136a3600d83613d0a565b91506136ae82614711565b602082019050919050565b60006136c6603183613d0a565b91506136d18261473a565b604082019050919050565b60006136e9602c83613d0a565b91506136f482614789565b604082019050919050565b600061370c603083613d0a565b9150613717826147d8565b604082019050919050565b600061372f603083613d0a565b915061373a82614827565b604082019050919050565b61374e81613ea5565b82525050565b61376561376082613ea5565b613fc1565b82525050565b600061377782856132fa565b915061378382846132fa565b91508190509392505050565b600061379b8287613754565b6020820191506137ab8286613262565b6014820191506137bb8285613754565b6020820191506137cb8284613754565b60208201915081905095945050505050565b60006020820190506137f26000830184613253565b92915050565b600060808201905061380d6000830187613253565b61381a6020830186613253565b6138276040830185613745565b81810360608301526138398184613288565b905095945050505050565b60006020820190506138596000830184613279565b92915050565b6000602082019050818103600083015261387981846132c1565b905092915050565b6000602082019050818103600083015261389a8161332b565b9050919050565b600060208201905081810360008301526138ba8161334e565b9050919050565b600060208201905081810360008301526138da81613371565b9050919050565b600060208201905081810360008301526138fa81613394565b9050919050565b6000602082019050818103600083015261391a816133b7565b9050919050565b6000602082019050818103600083015261393a816133da565b9050919050565b6000602082019050818103600083015261395a816133fd565b9050919050565b6000602082019050818103600083015261397a81613420565b9050919050565b6000602082019050818103600083015261399a81613443565b9050919050565b600060208201905081810360008301526139ba81613466565b9050919050565b600060208201905081810360008301526139da81613489565b9050919050565b600060208201905081810360008301526139fa816134ac565b9050919050565b60006020820190508181036000830152613a1a816134cf565b9050919050565b60006020820190508181036000830152613a3a816134f2565b9050919050565b60006020820190508181036000830152613a5a81613515565b9050919050565b60006020820190508181036000830152613a7a81613538565b9050919050565b60006020820190508181036000830152613a9a8161355b565b9050919050565b60006020820190508181036000830152613aba8161357e565b9050919050565b60006020820190508181036000830152613ada816135a1565b9050919050565b60006020820190508181036000830152613afa816135c4565b9050919050565b60006020820190508181036000830152613b1a816135e7565b9050919050565b60006020820190508181036000830152613b3a8161360a565b9050919050565b60006020820190508181036000830152613b5a8161362d565b9050919050565b60006020820190508181036000830152613b7a81613650565b9050919050565b60006020820190508181036000830152613b9a81613673565b9050919050565b60006020820190508181036000830152613bba81613696565b9050919050565b60006020820190508181036000830152613bda816136b9565b9050919050565b60006020820190508181036000830152613bfa816136dc565b9050919050565b60006020820190508181036000830152613c1a816136ff565b9050919050565b60006020820190508181036000830152613c3a81613722565b9050919050565b6000602082019050613c566000830184613745565b92915050565b6000613c66613c77565b9050613c728282613f23565b919050565b6000604051905090565b600067ffffffffffffffff821115613c9c57613c9b614089565b5b613ca5826140b8565b9050602081019050919050565b600067ffffffffffffffff821115613ccd57613ccc614089565b5b613cd6826140b8565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613d3182613ea5565b9150613d3c83613ea5565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613d7157613d70613ffc565b5b828201905092915050565b6000613d8782613ea5565b9150613d9283613ea5565b925082613da257613da161402b565b5b828204905092915050565b6000613db882613ea5565b9150613dc383613ea5565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613dfc57613dfb613ffc565b5b828202905092915050565b6000613e1282613ea5565b9150613e1d83613ea5565b925082821015613e3057613e2f613ffc565b5b828203905092915050565b6000613e4682613e85565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613edc578082015181840152602081019050613ec1565b83811115613eeb576000848401525b50505050565b60006002820490506001821680613f0957607f821691505b60208210811415613f1d57613f1c61405a565b5b50919050565b613f2c826140b8565b810181811067ffffffffffffffff82111715613f4b57613f4a614089565b5b80604052505050565b6000613f5f82613ea5565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613f9257613f91613ffc565b5b600182019050919050565b6000613fa882613faf565b9050919050565b6000613fba826140c9565b9050919050565b6000819050919050565b6000613fd682613ea5565b9150613fe183613ea5565b925082613ff157613ff061402b565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f6d73672e76616c756520696e76616c6964000000000000000000000000000000600082015250565b7f4d696e74207265717565737420657863656564732063757272656e742073757060008201527f706c792100000000000000000000000000000000000000000000000000000000602082015250565b7f4d696e742065786365656473206c696d6974207065722063616c6c2e00000000600082015250565b7f555249206e6f7420736574000000000000000000000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4d696e742072657175657374206578636565647320746f74616c20737570706c60008201527f7921000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f44657620737570706c792068617320616c7265616479206265656e206177617260008201527f6465640000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4d757374206d696e74206174206c65617374206f6e652e000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f53616c652068617320616c726561647920737461727465640000000000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f53616c6520686173206e6f742073746172746564207965742e00000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f507269636520746f6f206c6f7700000000000000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656400000000000000000000000000000000602082015250565b7f43616e2774206368616e6765206d65746164617461206166746572207468652060008201527f73616c6520686173207374617274656400000000000000000000000000000000602082015250565b61487f81613e3b565b811461488a57600080fd5b50565b61489681613e4d565b81146148a157600080fd5b50565b6148ad81613e59565b81146148b857600080fd5b50565b6148c481613ea5565b81146148cf57600080fd5b5056fea2646970667358221220a857eecc58477778967f6b3c85acb1b108d3aae8b3206b24a3efe97ce17e26fd64736f6c63430008040033
[ 10, 5 ]
0xf3cAdb0b3255544c6C37B797ff85D955121FdbB0
// SPDX-License-Identifier: MIT pragma solidity =0.8.10; abstract contract IDFSRegistry { function getAddr(bytes4 _id) public view virtual returns (address); function addNewContract( bytes32 _id, address _contractAddr, uint256 _waitPeriod ) public virtual; function startContractChange(bytes32 _id, address _newContractAddr) public virtual; function approveContractChange(bytes32 _id) public virtual; function cancelContractChange(bytes32 _id) public virtual; function changeWaitPeriod(bytes32 _id, uint256 _newWaitPeriod) public virtual; } interface IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint256 digits); function totalSupply() external view returns (uint256 supply); function balanceOf(address _owner) external view returns (uint256 balance); function transfer(address _to, uint256 _value) external returns (bool success); function transferFrom( address _from, address _to, uint256 _value ) external returns (bool success); function approve(address _spender, uint256 _value) external returns (bool success); function allowance(address _owner, address _spender) external view returns (uint256 remaining); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } library Address { //insufficient balance error InsufficientBalance(uint256 available, uint256 required); //unable to send value, recipient may have reverted error SendingValueFail(); //insufficient balance for call error InsufficientBalanceForCall(uint256 available, uint256 required); //call to non-contract error NonContractCall(); 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 { uint256 balance = address(this).balance; if (balance < amount){ revert InsufficientBalance(balance, amount); } // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(""); if (!(success)){ revert SendingValueFail(); } } 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) { uint256 balance = address(this).balance; if (balance < value){ revert InsufficientBalanceForCall(balance, value); } return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue( address target, bytes memory data, uint256 weiValue, string memory errorMessage ) private returns (bytes memory) { if (!(isContract(target))){ revert NonContractCall(); } // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: weiValue}(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer( 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 Edited so it always first approves 0 and then the value, because of non standard tokens function safeApprove( IERC20 token, address spender, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn( token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance) ); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value, "SafeERC20: decreased allowance below zero" ); _callOptionalReturn( token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance) ); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall( data, "SafeERC20: low-level call failed" ); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract MainnetAuthAddresses { address internal constant ADMIN_VAULT_ADDR = 0xCCf3d848e08b94478Ed8f46fFead3008faF581fD; address internal constant FACTORY_ADDRESS = 0x5a15566417e6C1c9546523066500bDDBc53F88C7; address internal constant ADMIN_ADDR = 0x25eFA336886C74eA8E282ac466BdCd0199f85BB9; // USED IN ADMIN VAULT CONSTRUCTOR } contract AuthHelper is MainnetAuthAddresses { } contract AdminVault is AuthHelper { address public owner; address public admin; error SenderNotAdmin(); constructor() { owner = msg.sender; admin = ADMIN_ADDR; } /// @notice Admin is able to change owner /// @param _owner Address of new owner function changeOwner(address _owner) public { if (admin != msg.sender){ revert SenderNotAdmin(); } owner = _owner; } /// @notice Admin is able to set new admin /// @param _admin Address of multisig that becomes new admin function changeAdmin(address _admin) public { if (admin != msg.sender){ revert SenderNotAdmin(); } admin = _admin; } } contract AdminAuth is AuthHelper { using SafeERC20 for IERC20; AdminVault public constant adminVault = AdminVault(ADMIN_VAULT_ADDR); error SenderNotOwner(); error SenderNotAdmin(); modifier onlyOwner() { if (adminVault.owner() != msg.sender){ revert SenderNotOwner(); } _; } modifier onlyAdmin() { if (adminVault.admin() != msg.sender){ revert SenderNotAdmin(); } _; } /// @notice withdraw stuck funds function withdrawStuckFunds(address _token, address _receiver, uint256 _amount) public onlyOwner { if (_token == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) { payable(_receiver).transfer(_amount); } else { IERC20(_token).safeTransfer(_receiver, _amount); } } /// @notice Destroy the contract function kill() public onlyAdmin { selfdestruct(payable(msg.sender)); } } contract DSMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x + y; } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x - y; } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x * y; } function div(uint256 x, uint256 y) internal pure returns (uint256 z) { return x / y; } function min(uint256 x, uint256 y) internal pure returns (uint256 z) { return x <= y ? x : y; } function max(uint256 x, uint256 y) internal pure returns (uint256 z) { return x >= y ? x : y; } function imin(int256 x, int256 y) internal pure returns (int256 z) { return x <= y ? x : y; } function imax(int256 x, int256 y) internal pure returns (int256 z) { return x >= y ? x : y; } uint256 constant WAD = 10**18; uint256 constant RAY = 10**27; function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), WAD / 2) / WAD; } function rmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, y), RAY / 2) / RAY; } function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, WAD), y / 2) / y; } function rdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = add(mul(x, RAY), y / 2) / y; } // This famous algorithm is called "exponentiation by squaring" // and calculates x^n with x as fixed-point and n as regular unsigned. // // It's O(log n), instead of O(n) for naive repeated multiplication. // // These facts are why it works: // // If n is even, then x^n = (x^2)^(n/2). // If n is odd, then x^n = x * x^(n-1), // and applying the equation for even x gives // x^n = x * (x^2)^((n-1) / 2). // // Also, EVM division is flooring and // floor[(n-1) / 2] = floor[n / 2]. // function rpow(uint256 x, uint256 n) internal pure returns (uint256 z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); if (n % 2 != 0) { z = rmul(z, x); } } } } abstract contract DSAuthority { function canCall( address src, address dst, bytes4 sig ) public view virtual returns (bool); } contract DSAuthEvents { event LogSetAuthority(address indexed authority); event LogSetOwner(address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; emit LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(address(authority)); } modifier auth { require(isAuthorized(msg.sender, msg.sig), "Not authorized"); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(address(0))) { return false; } else { return authority.canCall(src, address(this), sig); } } } contract DSNote { event LogNote( bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint256 wad, bytes fax ) anonymous; modifier note { bytes32 foo; bytes32 bar; assembly { foo := calldataload(4) bar := calldataload(36) } emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data); _; } } abstract contract DSProxy is DSAuth, DSNote { DSProxyCache public cache; // global cache for contracts constructor(address _cacheAddr) { if (!(setCache(_cacheAddr))){ require(isAuthorized(msg.sender, msg.sig), "Not authorized"); } } // solhint-disable-next-line no-empty-blocks receive() external payable {} // use the proxy to execute calldata _data on contract _code function execute(bytes memory _code, bytes memory _data) public payable virtual returns (address target, bytes32 response); function execute(address _target, bytes memory _data) public payable virtual returns (bytes32 response); //set new cache function setCache(address _cacheAddr) public payable virtual returns (bool); } contract DSProxyCache { mapping(bytes32 => address) cache; function read(bytes memory _code) public view returns (address) { bytes32 hash = keccak256(_code); return cache[hash]; } function write(bytes memory _code) public returns (address target) { assembly { target := create(0, add(_code, 0x20), mload(_code)) switch iszero(extcodesize(target)) case 1 { // throw if contract failed to deploy revert(0, 0) } } bytes32 hash = keccak256(_code); cache[hash] = target; } } abstract contract IManager { function last(address) virtual public returns (uint); function cdpCan(address, uint, address) virtual public view returns (uint); function ilks(uint) virtual public view returns (bytes32); function owns(uint) virtual public view returns (address); function urns(uint) virtual public view returns (address); function vat() virtual public view returns (address); function open(bytes32, address) virtual public returns (uint); function give(uint, address) virtual public; function cdpAllow(uint, address, uint) virtual public; function urnAllow(address, uint) virtual public; function frob(uint, int, int) virtual public; function flux(uint, address, uint) virtual public; function move(uint, address, uint) virtual public; function exit(address, uint, address, uint) virtual public; function quit(uint, address) virtual public; function enter(address, uint) virtual public; function shift(uint, uint) virtual public; } abstract contract IGem { function dec() virtual public returns (uint); function gem() virtual public returns (IGem); function join(address, uint) virtual public payable; function exit(address, uint) virtual public; function approve(address, uint) virtual public; function transfer(address, uint) virtual public returns (bool); function transferFrom(address, address, uint) virtual public returns (bool); function deposit() virtual public payable; function withdraw(uint) virtual public; function allowance(address, address) virtual public returns (uint); } abstract contract IJoin { bytes32 public ilk; function dec() virtual public view returns (uint); function gem() virtual public view returns (IGem); function join(address, uint) virtual public payable; function exit(address, uint) virtual public; } abstract contract IVat { struct Urn { uint256 ink; // Locked Collateral [wad] uint256 art; // Normalised Debt [wad] } struct Ilk { uint256 Art; // Total Normalised Debt [wad] uint256 rate; // Accumulated Rates [ray] uint256 spot; // Price with Safety Margin [ray] uint256 line; // Debt Ceiling [rad] uint256 dust; // Urn Debt Floor [rad] } mapping (bytes32 => mapping (address => Urn )) public urns; mapping (bytes32 => Ilk) public ilks; mapping (bytes32 => mapping (address => uint)) public gem; // [wad] function can(address, address) virtual public view returns (uint); function dai(address) virtual public view returns (uint); function frob(bytes32, address, address, address, int, int) virtual public; function hope(address) virtual public; function nope(address) virtual public; function move(address, address, uint) virtual public; function fork(bytes32, address, address, int, int) virtual public; } abstract contract IWETH { function allowance(address, address) public virtual view returns (uint256); function balanceOf(address) public virtual view returns (uint256); function approve(address, uint256) public virtual; function transfer(address, uint256) public virtual returns (bool); function transferFrom( address, address, uint256 ) public virtual returns (bool); function deposit() public payable virtual; function withdraw(uint256) public virtual; } library TokenUtils { using SafeERC20 for IERC20; address public constant WETH_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address public constant ETH_ADDR = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; function approveToken( address _tokenAddr, address _to, uint256 _amount ) internal { if (_tokenAddr == ETH_ADDR) return; if (IERC20(_tokenAddr).allowance(address(this), _to) < _amount) { IERC20(_tokenAddr).safeApprove(_to, _amount); } } function pullTokensIfNeeded( address _token, address _from, uint256 _amount ) internal returns (uint256) { // handle max uint amount if (_amount == type(uint256).max) { _amount = getBalance(_token, _from); } if (_from != address(0) && _from != address(this) && _token != ETH_ADDR && _amount != 0) { IERC20(_token).safeTransferFrom(_from, address(this), _amount); } return _amount; } function withdrawTokens( address _token, address _to, uint256 _amount ) internal returns (uint256) { if (_amount == type(uint256).max) { _amount = getBalance(_token, address(this)); } if (_to != address(0) && _to != address(this) && _amount != 0) { if (_token != ETH_ADDR) { IERC20(_token).safeTransfer(_to, _amount); } else { (bool success, ) = _to.call{value: _amount}(""); require(success, "Eth send fail"); } } return _amount; } function depositWeth(uint256 _amount) internal { IWETH(WETH_ADDR).deposit{value: _amount}(); } function withdrawWeth(uint256 _amount) internal { IWETH(WETH_ADDR).withdraw(_amount); } function getBalance(address _tokenAddr, address _acc) internal view returns (uint256) { if (_tokenAddr == ETH_ADDR) { return _acc.balance; } else { return IERC20(_tokenAddr).balanceOf(_acc); } } function getTokenDecimals(address _token) internal view returns (uint256) { if (_token == ETH_ADDR) return 18; return IERC20(_token).decimals(); } } abstract contract IPipInterface { function read() public virtual returns (bytes32); function poke() external virtual; } abstract contract ISpotter { struct Ilk { IPipInterface pip; uint256 mat; } mapping (bytes32 => Ilk) public ilks; uint256 public par; } contract McdRatioHelper is DSMath { IVat public constant vat = IVat(0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B); ISpotter public constant spotter = ISpotter(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3); IManager public constant manager = IManager(0x5ef30b9986345249bc32d8928B7ee64DE9435E39); /// @notice Gets CDP ratio /// @param _vaultId Id of the CDP /// @param _nextPrice Next price for user function getRatio(uint256 _vaultId, uint256 _nextPrice) public view returns (uint256) { bytes32 ilk = manager.ilks(_vaultId); uint256 price = (_nextPrice == 0) ? getPrice(ilk) : _nextPrice; (uint256 collateral, uint256 debt) = getCdpInfo(_vaultId, ilk); if (debt == 0) return 0; return rdiv(wmul(collateral, price), debt) / (10**18); } /// @notice Gets CDP info (collateral, debt) /// @param _vaultId Id of the CDP /// @param _ilk Ilk of the CDP function getCdpInfo(uint256 _vaultId, bytes32 _ilk) public view returns (uint256, uint256) { address urn = manager.urns(_vaultId); (uint256 collateral, uint256 debt) = vat.urns(_ilk, urn); (, uint256 rate, , , ) = vat.ilks(_ilk); return (collateral, rmul(debt, rate)); } /// @notice Gets a price of the asset /// @param _ilk Ilk of the CDP function getPrice(bytes32 _ilk) public view returns (uint256) { (, uint256 mat) = spotter.ilks(_ilk); (, , uint256 spot, , ) = vat.ilks(_ilk); return rmul(rmul(spot, spotter.par()), mat); } } abstract contract ITrigger { function isTriggered(bytes memory, bytes memory) public virtual returns (bool); function isChangeable() public virtual returns (bool); function changedSubData(bytes memory) public virtual returns (bytes memory); } abstract contract IMCDPriceVerifier { function verifyVaultNextPrice(uint _nextPrice, uint _cdpId) public view virtual returns(bool); function verifyNextPrice(uint _nextPrice, bytes32 _ilk) public view virtual returns(bool); function setAuthorized(address _address, bool _allowed) public virtual; } contract MainnetCoreAddresses { address internal constant REGISTRY_ADDR = 0x287778F121F134C66212FB16c9b53eC991D32f5b; address internal constant PROXY_AUTH_ADDR = 0x149667b6FAe2c63D1B4317C716b0D0e4d3E2bD70; address internal constant DEFISAVER_LOGGER = 0xcE7a977Cac4a481bc84AC06b2Da0df614e621cf3; address internal constant SUB_STORAGE_ADDR = 0x1612fc28Ee0AB882eC99842Cde0Fc77ff0691e90; address internal constant BUNDLE_STORAGE_ADDR = 0x223c6aDE533851Df03219f6E3D8B763Bd47f84cf; address internal constant STRATEGY_STORAGE_ADDR = 0xF52551F95ec4A2B4299DcC42fbbc576718Dbf933; } contract CoreHelper is MainnetCoreAddresses { } contract DFSRegistry is AdminAuth { error EntryAlreadyExistsError(bytes4); error EntryNonExistentError(bytes4); error EntryNotInChangeError(bytes4); error ChangeNotReadyError(uint256,uint256); error EmptyPrevAddrError(bytes4); error AlreadyInContractChangeError(bytes4); error AlreadyInWaitPeriodChangeError(bytes4); event AddNewContract(address,bytes4,address,uint256); event RevertToPreviousAddress(address,bytes4,address,address); event StartContractChange(address,bytes4,address,address); event ApproveContractChange(address,bytes4,address,address); event CancelContractChange(address,bytes4,address,address); event StartWaitPeriodChange(address,bytes4,uint256); event ApproveWaitPeriodChange(address,bytes4,uint256,uint256); event CancelWaitPeriodChange(address,bytes4,uint256,uint256); struct Entry { address contractAddr; uint256 waitPeriod; uint256 changeStartTime; bool inContractChange; bool inWaitPeriodChange; bool exists; } mapping(bytes4 => Entry) public entries; mapping(bytes4 => address) public previousAddresses; mapping(bytes4 => address) public pendingAddresses; mapping(bytes4 => uint256) public pendingWaitTimes; /// @notice Given an contract id returns the registered address /// @dev Id is keccak256 of the contract name /// @param _id Id of contract function getAddr(bytes4 _id) public view returns (address) { return entries[_id].contractAddr; } /// @notice Helper function to easily query if id is registered /// @param _id Id of contract function isRegistered(bytes4 _id) public view returns (bool) { return entries[_id].exists; } /////////////////////////// OWNER ONLY FUNCTIONS /////////////////////////// /// @notice Adds a new contract to the registry /// @param _id Id of contract /// @param _contractAddr Address of the contract /// @param _waitPeriod Amount of time to wait before a contract address can be changed function addNewContract( bytes4 _id, address _contractAddr, uint256 _waitPeriod ) public onlyOwner { if (entries[_id].exists){ revert EntryAlreadyExistsError(_id); } entries[_id] = Entry({ contractAddr: _contractAddr, waitPeriod: _waitPeriod, changeStartTime: 0, inContractChange: false, inWaitPeriodChange: false, exists: true }); emit AddNewContract(msg.sender, _id, _contractAddr, _waitPeriod); } /// @notice Reverts to the previous address immediately /// @dev In case the new version has a fault, a quick way to fallback to the old contract /// @param _id Id of contract function revertToPreviousAddress(bytes4 _id) public onlyOwner { if (!(entries[_id].exists)){ revert EntryNonExistentError(_id); } if (previousAddresses[_id] == address(0)){ revert EmptyPrevAddrError(_id); } address currentAddr = entries[_id].contractAddr; entries[_id].contractAddr = previousAddresses[_id]; emit RevertToPreviousAddress(msg.sender, _id, currentAddr, previousAddresses[_id]); } /// @notice Starts an address change for an existing entry /// @dev Can override a change that is currently in progress /// @param _id Id of contract /// @param _newContractAddr Address of the new contract function startContractChange(bytes4 _id, address _newContractAddr) public onlyOwner { if (!entries[_id].exists){ revert EntryNonExistentError(_id); } if (entries[_id].inWaitPeriodChange){ revert AlreadyInWaitPeriodChangeError(_id); } entries[_id].changeStartTime = block.timestamp; // solhint-disable-line entries[_id].inContractChange = true; pendingAddresses[_id] = _newContractAddr; emit StartContractChange(msg.sender, _id, entries[_id].contractAddr, _newContractAddr); } /// @notice Changes new contract address, correct time must have passed /// @param _id Id of contract function approveContractChange(bytes4 _id) public onlyOwner { if (!entries[_id].exists){ revert EntryNonExistentError(_id); } if (!entries[_id].inContractChange){ revert EntryNotInChangeError(_id); } if (block.timestamp < (entries[_id].changeStartTime + entries[_id].waitPeriod)){// solhint-disable-line revert ChangeNotReadyError(block.timestamp, (entries[_id].changeStartTime + entries[_id].waitPeriod)); } address oldContractAddr = entries[_id].contractAddr; entries[_id].contractAddr = pendingAddresses[_id]; entries[_id].inContractChange = false; entries[_id].changeStartTime = 0; pendingAddresses[_id] = address(0); previousAddresses[_id] = oldContractAddr; emit ApproveContractChange(msg.sender, _id, oldContractAddr, entries[_id].contractAddr); } /// @notice Cancel pending change /// @param _id Id of contract function cancelContractChange(bytes4 _id) public onlyOwner { if (!entries[_id].exists){ revert EntryNonExistentError(_id); } if (!entries[_id].inContractChange){ revert EntryNotInChangeError(_id); } address oldContractAddr = pendingAddresses[_id]; pendingAddresses[_id] = address(0); entries[_id].inContractChange = false; entries[_id].changeStartTime = 0; emit CancelContractChange(msg.sender, _id, oldContractAddr, entries[_id].contractAddr); } /// @notice Starts the change for waitPeriod /// @param _id Id of contract /// @param _newWaitPeriod New wait time function startWaitPeriodChange(bytes4 _id, uint256 _newWaitPeriod) public onlyOwner { if (!entries[_id].exists){ revert EntryNonExistentError(_id); } if (entries[_id].inContractChange){ revert AlreadyInContractChangeError(_id); } pendingWaitTimes[_id] = _newWaitPeriod; entries[_id].changeStartTime = block.timestamp; // solhint-disable-line entries[_id].inWaitPeriodChange = true; emit StartWaitPeriodChange(msg.sender, _id, _newWaitPeriod); } /// @notice Changes new wait period, correct time must have passed /// @param _id Id of contract function approveWaitPeriodChange(bytes4 _id) public onlyOwner { if (!entries[_id].exists){ revert EntryNonExistentError(_id); } if (!entries[_id].inWaitPeriodChange){ revert EntryNotInChangeError(_id); } if (block.timestamp < (entries[_id].changeStartTime + entries[_id].waitPeriod)){ // solhint-disable-line revert ChangeNotReadyError(block.timestamp, (entries[_id].changeStartTime + entries[_id].waitPeriod)); } uint256 oldWaitTime = entries[_id].waitPeriod; entries[_id].waitPeriod = pendingWaitTimes[_id]; entries[_id].inWaitPeriodChange = false; entries[_id].changeStartTime = 0; pendingWaitTimes[_id] = 0; emit ApproveWaitPeriodChange(msg.sender, _id, oldWaitTime, entries[_id].waitPeriod); } /// @notice Cancel wait period change /// @param _id Id of contract function cancelWaitPeriodChange(bytes4 _id) public onlyOwner { if (!entries[_id].exists){ revert EntryNonExistentError(_id); } if (!entries[_id].inWaitPeriodChange){ revert EntryNotInChangeError(_id); } uint256 oldWaitPeriod = pendingWaitTimes[_id]; pendingWaitTimes[_id] = 0; entries[_id].inWaitPeriodChange = false; entries[_id].changeStartTime = 0; emit CancelWaitPeriodChange(msg.sender, _id, oldWaitPeriod, entries[_id].waitPeriod); } } contract MainnetTriggerAddresses { address public constant CHAINLINK_FEED_REGISTRY = 0x47Fb2585D2C56Fe188D0E6ec628a38b74fCeeeDf; address public constant UNISWAP_V3_NONFUNGIBLE_POSITION_MANAGER = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88; address public constant UNISWAP_V3_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984; address public constant MCD_PRICE_VERIFIER = 0xeAa474cbFFA87Ae0F1a6f68a3aBA6C77C656F72c; address internal constant WSTETH_ADDR = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; address internal constant STETH_ADDR = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84; } contract TriggerHelper is MainnetTriggerAddresses { } contract McdRatioTrigger is ITrigger, AdminAuth, McdRatioHelper, CoreHelper, TriggerHelper { DFSRegistry public constant registry = DFSRegistry(REGISTRY_ADDR); error WrongNextPrice(uint256); enum RatioState { OVER, UNDER } enum RatioCheck { CURR_RATIO, NEXT_RATIO, BOTH_RATIOS } /// @param nextPrice price that OSM returns as next price value /// @param ratioCheck returns if we want the trigger to look at the current asset price, nextPrice param or both struct CallParams { uint256 nextPrice; uint8 ratioCheck; } /// @param vaultId id of the vault whose ratio we check /// @param ratio ratio that represents the triggerable point /// @param state represents if we want current ratio to be higher or lower than ratio param struct SubParams { uint256 vaultId; uint256 ratio; uint8 state; } function isTriggered(bytes memory _callData, bytes memory _subData) public override returns (bool) { CallParams memory triggerCallData = parseCallInputs(_callData); SubParams memory triggerSubData = parseSubInputs(_subData); uint256 checkedRatio; bool shouldTriggerCurr; bool shouldTriggerNext; if (RatioCheck(triggerCallData.ratioCheck) == RatioCheck.CURR_RATIO || RatioCheck(triggerCallData.ratioCheck) == RatioCheck.BOTH_RATIOS){ checkedRatio = getRatio(triggerSubData.vaultId, 0); // if cdp has 0 ratio don't trigger it if (checkedRatio == 0) return false; shouldTriggerCurr = shouldTrigger(triggerSubData.state, checkedRatio, triggerSubData.ratio); } if (RatioCheck(triggerCallData.ratioCheck) == RatioCheck.NEXT_RATIO || RatioCheck(triggerCallData.ratioCheck) == RatioCheck.BOTH_RATIOS){ checkedRatio = getRatio(triggerSubData.vaultId, triggerCallData.nextPrice); // if cdp has 0 ratio don't trigger it if (checkedRatio == 0) return false; shouldTriggerNext = shouldTrigger(triggerSubData.state, checkedRatio, triggerSubData.ratio); // must convert back to wad if (triggerCallData.nextPrice != 0) { triggerCallData.nextPrice = triggerCallData.nextPrice / 1e9; } /// @dev if we don't have access to the next price on-chain this returns true, if we do this compares the nextPrice param we sent if ( !IMCDPriceVerifier(MCD_PRICE_VERIFIER).verifyVaultNextPrice( triggerCallData.nextPrice, triggerSubData.vaultId ) ) { revert WrongNextPrice(triggerCallData.nextPrice); } } return shouldTriggerCurr || shouldTriggerNext; } function shouldTrigger(uint8 state, uint256 checkedRatio, uint256 subbedToRatio) internal pure returns (bool){ if (RatioState(state) == RatioState.OVER) { if (checkedRatio > subbedToRatio) return true; } if (RatioState(state) == RatioState.UNDER) { if (checkedRatio < subbedToRatio) return true; } return false; } function changedSubData(bytes memory _subData) public pure override returns (bytes memory) {} function isChangeable() public pure override returns (bool) { return false; } function parseCallInputs(bytes memory _callData) internal pure returns (CallParams memory params) { params = abi.decode(_callData, (CallParams)); } function parseSubInputs(bytes memory _subData) internal pure returns (SubParams memory params) { params = abi.decode(_subData, (SubParams)); } }
0x608060405234801561001057600080fd5b506004361061011b5760003560e01c80637d9f7712116100b2578063ab9772ac11610081578063c579d49011610066578063c579d490146102c0578063cff70001146102d3578063f73e5aab146102e657600080fd5b8063ab9772ac14610291578063c42498ea1461029857600080fd5b80637d9f77121461021d5780638cedca7114610238578063917897761461025357806391a973c61461026e57600080fd5b806341c0e1b5116100ee57806341c0e1b5146101bc578063481c6a75146101c65780637b103999146101e15780637c331ddb146101fc57600080fd5b80632aad74d3146101205780632e77468d1461016557806331d98b3f1461018057806336569e77146101a1575b600080fd5b61013b73eaa474cbffa87ae0f1a6f68a3aba6c77c656f72c81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61013b7365c79fcb50ca1594b025960e539ed7a9a6d434a381565b61019361018e366004611120565b610301565b60405190815260200161015c565b61013b7335d1b3f3d7966a1dfe207aa4514c12a259a0492b81565b6101c46104c9565b005b61013b735ef30b9986345249bc32d8928b7ee64de9435e3981565b61013b73287778f121f134c66212fb16c9b53ec991d32f5b81565b61021061020a366004611213565b50606090565b60405161015c91906112be565b61013b7347fb2585d2c56fe188d0e6ec628a38b74fceeedf81565b61013b73ccf3d848e08b94478ed8f46ffead3008faf581fd81565b61013b73c36442b4a4522e871399cd717abdd847ab11fe8881565b61028161027c3660046112d1565b6105b3565b604051901515815260200161015c565b6000610281565b6102ab6102a6366004611335565b61081d565b6040805192835260208301919091520161015c565b6101c46102ce36600461137c565b610a16565b6101936102e1366004611335565b610b9e565b61013b731f98431c8ad98523631ae4a59f267346ea31f98481565b6040517fd9638d360000000000000000000000000000000000000000000000000000000081526004810182905260009081907365c79fcb50ca1594b025960e539ed7a9a6d434a39063d9638d36906024016040805180830381865afa15801561036e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061039291906113bd565b6040517fd9638d3600000000000000000000000000000000000000000000000000000000815260048101869052909250600091507335d1b3f3d7966a1dfe207aa4514c12a259a0492b9063d9638d369060240160a060405180830381865afa158015610402573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042691906113eb565b5050925050506104c16104bb827365c79fcb50ca1594b025960e539ed7a9a6d434a373ffffffffffffffffffffffffffffffffffffffff1663495d32cb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610492573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b6919061142b565b610ca3565b83610ca3565b949350505050565b3373ffffffffffffffffffffffffffffffffffffffff1673ccf3d848e08b94478ed8f46ffead3008faf581fd73ffffffffffffffffffffffffffffffffffffffff1663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa15801561053f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105639190611444565b73ffffffffffffffffffffffffffffffffffffffff16146105b0576040517fa6c827a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33ff5b6000806105bf84610cec565b905060006105cc84610d14565b90506000808080856020015160ff1660028111156105ec576105ec611461565b60028111156105fd576105fd611461565b148061063257506002856020015160ff16600281111561061f5761061f611461565b600281111561063057610630611461565b145b1561066f578351610644906000610b9e565b92508261065957600095505050505050610817565b61066c8460400151848660200151610d4f565b91505b6001856020015160ff16600281111561068a5761068a611461565b600281111561069b5761069b611461565b14806106d057506002856020015160ff1660028111156106bd576106bd611461565b60028111156106ce576106ce611461565b145b1561080657835185516106e39190610b9e565b9250826106f857600095505050505050610817565b61070b8460400151848660200151610d4f565b85519091501561072957845161072690633b9aca00906114bf565b85525b845184516040517f1c6dd45a00000000000000000000000000000000000000000000000000000000815273eaa474cbffa87ae0f1a6f68a3aba6c77c656f72c92631c6dd45a9261078492600401918252602082015260400190565b602060405180830381865afa1580156107a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c591906114fa565b6108065784516040517fb53202c700000000000000000000000000000000000000000000000000000000815260048101919091526024015b60405180910390fd5b818061080f5750805b955050505050505b92915050565b6040517f2726b0730000000000000000000000000000000000000000000000000000000081526004810183905260009081908190735ef30b9986345249bc32d8928b7ee64de9435e3990632726b07390602401602060405180830381865afa15801561088d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b19190611444565b6040517f2424be5c0000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff8216602482015290915060009081907335d1b3f3d7966a1dfe207aa4514c12a259a0492b90632424be5c906044016040805180830381865afa15801561093d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610961919061151c565b6040517fd9638d360000000000000000000000000000000000000000000000000000000081526004810189905291935091506000907335d1b3f3d7966a1dfe207aa4514c12a259a0492b9063d9638d369060240160a060405180830381865afa1580156109d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f691906113eb565b50505091505082610a078383610ca3565b95509550505050509250929050565b3373ffffffffffffffffffffffffffffffffffffffff1673ccf3d848e08b94478ed8f46ffead3008faf581fd73ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab09190611444565b73ffffffffffffffffffffffffffffffffffffffff1614610afd576040517f19494c8a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee73ffffffffffffffffffffffffffffffffffffffff84161415610b785760405173ffffffffffffffffffffffffffffffffffffffff83169082156108fc029083906000818181858888f19350505050158015610b72573d6000803e3d6000fd5b50505050565b610b9973ffffffffffffffffffffffffffffffffffffffff84168383610dd6565b505050565b6040517f2c2cb9fd000000000000000000000000000000000000000000000000000000008152600481018390526000908190735ef30b9986345249bc32d8928b7ee64de9435e3990632c2cb9fd90602401602060405180830381865afa158015610c0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c30919061142b565b905060008315610c405783610c49565b610c4982610301565b9050600080610c58878561081d565b915091508060001415610c72576000945050505050610817565b670de0b6b3a7640000610c8e610c888486610e63565b83610e8e565b610c9891906114bf565b979650505050505050565b60006b033b2e3c9fd0803ce8000000610cdb610cbf8585610eb5565b610cd660026b033b2e3c9fd0803ce80000006114bf565b610ec1565b610ce591906114bf565b9392505050565b6040805180820190915260008082526020820152818060200190518101906108179190611556565b610d3b60405180606001604052806000815260200160008152602001600060ff1681525090565b8180602001905181019061081791906115aa565b6000808460ff166001811115610d6757610d67611461565b6001811115610d7857610d78611461565b1415610d8e5781831115610d8e57506001610ce5565b60018460ff166001811115610da557610da5611461565b6001811115610db657610db6611461565b1415610dcc5781831015610dcc57506001610ce5565b5060009392505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610b99908490610ecd565b6000670de0b6b3a7640000610cdb610e7b8585610eb5565b610cd66002670de0b6b3a76400006114bf565b600081610cdb610eaa856b033b2e3c9fd0803ce8000000610eb5565b610cd66002866114bf565b6000610ce5828461160a565b6000610ce58284611647565b6000610f2f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610fd99092919063ffffffff16565b805190915015610b995780806020019051810190610f4d91906114fa565b610b99576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107fd565b60606104c184846000856060610fee856110e7565b611024576040517f304619b500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161104d919061165f565b60006040518083038185875af1925050503d806000811461108a576040519150601f19603f3d011682016040523d82523d6000602084013e61108f565b606091505b509150915081156110a35791506104c19050565b8051156110b35780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107fd91906112be565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708181148015906104c1575050151592915050565b60006020828403121561113257600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261117957600080fd5b813567ffffffffffffffff8082111561119457611194611139565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156111da576111da611139565b816040528381528660208588010111156111f357600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561122557600080fd5b813567ffffffffffffffff81111561123c57600080fd5b6104c184828501611168565b60005b8381101561126357818101518382015260200161124b565b83811115610b725750506000910152565b6000815180845261128c816020860160208601611248565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000610ce56020830184611274565b600080604083850312156112e457600080fd5b823567ffffffffffffffff808211156112fc57600080fd5b61130886838701611168565b9350602085013591508082111561131e57600080fd5b5061132b85828601611168565b9150509250929050565b6000806040838503121561134857600080fd5b50508035926020909101359150565b73ffffffffffffffffffffffffffffffffffffffff8116811461137957600080fd5b50565b60008060006060848603121561139157600080fd5b833561139c81611357565b925060208401356113ac81611357565b929592945050506040919091013590565b600080604083850312156113d057600080fd5b82516113db81611357565b6020939093015192949293505050565b600080600080600060a0868803121561140357600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b60006020828403121561143d57600080fd5b5051919050565b60006020828403121561145657600080fd5b8151610ce581611357565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000826114f5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60006020828403121561150c57600080fd5b81518015158114610ce557600080fd5b6000806040838503121561152f57600080fd5b505080516020909101519092909150565b805160ff8116811461155157600080fd5b919050565b60006040828403121561156857600080fd5b6040516040810181811067ffffffffffffffff8211171561158b5761158b611139565b6040528251815261159e60208401611540565b60208201529392505050565b6000606082840312156115bc57600080fd5b6040516060810181811067ffffffffffffffff821117156115df576115df611139565b806040525082518152602083015160208201526115fe60408401611540565b60408201529392505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561164257611642611490565b500290565b6000821982111561165a5761165a611490565b500190565b60008251611671818460208701611248565b919091019291505056fea2646970667358221220877b54500eb7a4d40e9eb362a85832ad9a8b9c7d9bcf55ef1e5ac48d5f80372864736f6c634300080a0033
[ 12, 17, 2 ]
0xf3cbada14d006134d5a1dbd50f63f926ce60c0dd
// Sources flattened with hardhat v2.3.0 https://hardhat.org // File @openzeppelin/contracts/token/ERC20/[email protected] // 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); } // File @openzeppelin/contracts/token/ERC20/extensions/[email protected] 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/[email protected] 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/[email protected] 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/access/[email protected] 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. */ 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 BasicERC20.sol pragma solidity ^0.8.0; contract zenditEQX is Ownable, ERC20{ constructor (string memory name, string memory symbol) ERC20(name, symbol) Ownable(){ uint256 mintAmount = 93750 * 10**18; _mint(msg.sender, mintAmount); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063a457c2d711610066578063a457c2d71461024f578063a9059cbb1461027f578063dd62ed3e146102af578063f2fde38b146102df576100ea565b8063715018a6146102095780638da5cb5b1461021357806395d89b4114610231576100ea565b806323b872dd116100c857806323b872dd1461015b578063313ce5671461018b57806339509351146101a957806370a08231146101d9576100ea565b806306fdde03146100ef578063095ea7b31461010d57806318160ddd1461013d575b600080fd5b6100f76102fb565b6040516101049190611245565b60405180910390f35b61012760048036038101906101229190611023565b61038d565b604051610134919061122a565b60405180910390f35b6101456103ab565b6040516101529190611387565b60405180910390f35b61017560048036038101906101709190610fd4565b6103b5565b604051610182919061122a565b60405180910390f35b6101936104b6565b6040516101a091906113a2565b60405180910390f35b6101c360048036038101906101be9190611023565b6104bf565b6040516101d0919061122a565b60405180910390f35b6101f360048036038101906101ee9190610f6f565b61056b565b6040516102009190611387565b60405180910390f35b6102116105b4565b005b61021b6106ee565b604051610228919061120f565b60405180910390f35b610239610717565b6040516102469190611245565b60405180910390f35b61026960048036038101906102649190611023565b6107a9565b604051610276919061122a565b60405180910390f35b61029960048036038101906102949190611023565b61089d565b6040516102a6919061122a565b60405180910390f35b6102c960048036038101906102c49190610f98565b6108bb565b6040516102d69190611387565b60405180910390f35b6102f960048036038101906102f49190610f6f565b610942565b005b60606004805461030a906114eb565b80601f0160208091040260200160405190810160405280929190818152602001828054610336906114eb565b80156103835780601f1061035857610100808354040283529160200191610383565b820191906000526020600020905b81548152906001019060200180831161036657829003601f168201915b5050505050905090565b60006103a161039a610aeb565b8484610af3565b6001905092915050565b6000600354905090565b60006103c2848484610cbe565b6000600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061040d610aeb565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561048d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610484906112e7565b60405180910390fd5b6104aa85610499610aeb565b85846104a5919061142f565b610af3565b60019150509392505050565b60006012905090565b60006105616104cc610aeb565b8484600260006104da610aeb565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461055c91906113d9565b610af3565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6105bc610aeb565b73ffffffffffffffffffffffffffffffffffffffff166105da6106ee565b73ffffffffffffffffffffffffffffffffffffffff1614610630576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062790611307565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054610726906114eb565b80601f0160208091040260200160405190810160405280929190818152602001828054610752906114eb565b801561079f5780601f106107745761010080835404028352916020019161079f565b820191906000526020600020905b81548152906001019060200180831161078257829003601f168201915b5050505050905090565b600080600260006107b8610aeb565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610875576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086c90611367565b60405180910390fd5b610892610880610aeb565b85858461088d919061142f565b610af3565b600191505092915050565b60006108b16108aa610aeb565b8484610cbe565b6001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61094a610aeb565b73ffffffffffffffffffffffffffffffffffffffff166109686106ee565b73ffffffffffffffffffffffffffffffffffffffff16146109be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b590611307565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2590611287565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5a90611347565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bca906112a7565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610cb19190611387565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d2590611327565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9590611267565b60405180910390fd5b610da9838383610f40565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610e30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e27906112c7565b60405180910390fd5b8181610e3c919061142f565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ece91906113d9565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610f329190611387565b60405180910390a350505050565b505050565b600081359050610f548161182d565b92915050565b600081359050610f6981611844565b92915050565b600060208284031215610f8157600080fd5b6000610f8f84828501610f45565b91505092915050565b60008060408385031215610fab57600080fd5b6000610fb985828601610f45565b9250506020610fca85828601610f45565b9150509250929050565b600080600060608486031215610fe957600080fd5b6000610ff786828701610f45565b935050602061100886828701610f45565b925050604061101986828701610f5a565b9150509250925092565b6000806040838503121561103657600080fd5b600061104485828601610f45565b925050602061105585828601610f5a565b9150509250929050565b61106881611463565b82525050565b61107781611475565b82525050565b6000611088826113bd565b61109281856113c8565b93506110a28185602086016114b8565b6110ab8161157b565b840191505092915050565b60006110c36023836113c8565b91506110ce8261158c565b604082019050919050565b60006110e66026836113c8565b91506110f1826115db565b604082019050919050565b60006111096022836113c8565b91506111148261162a565b604082019050919050565b600061112c6026836113c8565b915061113782611679565b604082019050919050565b600061114f6028836113c8565b915061115a826116c8565b604082019050919050565b60006111726020836113c8565b915061117d82611717565b602082019050919050565b60006111956025836113c8565b91506111a082611740565b604082019050919050565b60006111b86024836113c8565b91506111c38261178f565b604082019050919050565b60006111db6025836113c8565b91506111e6826117de565b604082019050919050565b6111fa816114a1565b82525050565b611209816114ab565b82525050565b6000602082019050611224600083018461105f565b92915050565b600060208201905061123f600083018461106e565b92915050565b6000602082019050818103600083015261125f818461107d565b905092915050565b60006020820190508181036000830152611280816110b6565b9050919050565b600060208201905081810360008301526112a0816110d9565b9050919050565b600060208201905081810360008301526112c0816110fc565b9050919050565b600060208201905081810360008301526112e08161111f565b9050919050565b6000602082019050818103600083015261130081611142565b9050919050565b6000602082019050818103600083015261132081611165565b9050919050565b6000602082019050818103600083015261134081611188565b9050919050565b60006020820190508181036000830152611360816111ab565b9050919050565b60006020820190508181036000830152611380816111ce565b9050919050565b600060208201905061139c60008301846111f1565b92915050565b60006020820190506113b76000830184611200565b92915050565b600081519050919050565b600082825260208201905092915050565b60006113e4826114a1565b91506113ef836114a1565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156114245761142361151d565b5b828201905092915050565b600061143a826114a1565b9150611445836114a1565b9250828210156114585761145761151d565b5b828203905092915050565b600061146e82611481565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156114d65780820151818401526020810190506114bb565b838111156114e5576000848401525b50505050565b6000600282049050600182168061150357607f821691505b602082108114156115175761151661154c565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b61183681611463565b811461184157600080fd5b50565b61184d816114a1565b811461185857600080fd5b5056fea2646970667358221220e089002ede2d3f5887a0b864a5d3b4301888f7adb1d69db096bdbfa0af047ae464736f6c63430008040033
[ 38 ]
0xF3Cc381600636C8E2682AD9B8b1BC2B381747828
// Sources flattened with hardhat v2.8.2 https://hardhat.org // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.4.2 // 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); } // File @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (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@v4.4.2 // 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/token/ERC20/ERC20.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (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 @openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol) pragma solidity ^0.8.0; /** * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { uint256 private immutable _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor(uint256 cap_) { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view virtual returns (uint256) { return _cap; } /** * @dev See {ERC20-_mint}. */ function _mint(address account, uint256 amount) internal virtual override { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } } // File @openzeppelin/contracts/access/Ownable.sol@v4.4.2 // 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 contracts/MediciToken.sol pragma solidity 0.8.9; /// @title MediciToken /// @dev Florence Finance Governance Token contract MediciToken is Ownable, ERC20Capped { /// @dev Initialize ERC with name 'Medici Token', symbol 'MDC' and 1 billion supply cap constructor() ERC20("Medici Token", "MDC") ERC20Capped(1_000_000_000 * 10**18) {} /// @dev Allows owners to mint MDC tokens. // After the MVP phase all tokens will be minted and sent to a timelock contract implementing a vesting schedule /// @param _receiver (address) address to receive the tokens /// @param _amount (uint256) amount to mint (18 decimals) function mint(address _receiver, uint256 _amount) external onlyOwner { require(_amount > 0, "MediciToken: invalidAmount"); _mint(_receiver, _amount); } /// @dev Allows anyone to burn their own MDC tokens /// @param _amount (uint256) amount to burn (18 decimals) function burn(uint256 _amount) external { require(_amount > 0, "MediciToken: invalidAmount"); _burn(msg.sender, _amount); } } // File @openzeppelin/contracts/utils/Address.sol@v4.4.2 // 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/ERC20/utils/SafeERC20.sol@v4.4.2 // OpenZeppelin Contracts v4.4.1 (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/TokenVestingWallet.sol // OpenZeppelin Contracts v4.4.1 (finance/VestingWallet.sol) pragma solidity ^0.8.0; /** * Based on: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/finance/VestingWallet.sol * * @dev This contract handles the vesting tokens for a given beneficiary following a linear vesting schedule. * * Any tokens transferred to this contract will follow the vesting schedule as if they were locked from the beginning. * Consequently, if the vesting has already started, any amount of tokens sent to this contract will (at least partly) * be immediately releasable. */ contract TokenVestingWallet { uint64 public immutable start; uint64 public immutable duration; address public token; address public beneficiary; uint256 public released; event TokensReleased(address _token, uint256 _amount); event BeneficiaryChanged(address _oldBeneficiary, address _newBeneficiary); /** * @dev Set the token, beneficiary, start timestamp and vesting duration of the vesting wallet. */ constructor( address _token, address _beneficiary, uint64 _startTimestamp, uint64 _durationSeconds ) { require(_token != address(0), "TokenVestingWallet: token is zero address"); require(_beneficiary != address(0), "TokenVestingWallet: beneficiary is zero address"); token = _token; beneficiary = _beneficiary; start = _startTimestamp; duration = _durationSeconds; } /** * @dev Allow beneficiary to change wallet address * * Emits a {BeneficiaryChanged} event. */ function setBeneficiary(address _beneficiary) public { require(msg.sender == beneficiary, "TokenVestingWallet: only beneficiary"); require(_beneficiary != address(0), "TokenVestingWallet: beneficiary is zero address"); emit BeneficiaryChanged(beneficiary, _beneficiary); beneficiary = _beneficiary; } /** * @dev Release the tokens that have already vested to the beneficiary wallet. This function can be called by anyone. * Emits a {TokensReleased} event. */ function release() public { uint256 releasable = vestedAmount(uint64(block.timestamp)) - released; if (releasable > 0) { released += releasable; emit TokensReleased(token, releasable); SafeERC20.safeTransfer(IERC20(token), beneficiary, releasable); } } /** * @dev Calculates the amount of tokens that have already vested. Implementation is a linear vesting curve. */ function vestedAmount(uint64 timestamp) public view returns (uint256) { uint256 totalAllocation = IERC20(token).balanceOf(address(this)) + released; if (timestamp < start) { return 0; } else if (timestamp > start + duration) { return totalAllocation; } else { return (totalAllocation * (timestamp - start)) / duration; } } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c806386d1a69f1161005b57806386d1a69f14610115578063961325211461011f578063be9a65551461013d578063fc0c546a1461015b57610088565b80630a17b06b1461008d5780630fb5a6b4146100bd5780631c31f710146100db57806338af3eed146100f7575b600080fd5b6100a760048036038101906100a291906109be565b610179565b6040516100b49190610a04565b60405180910390f35b6100c5610369565b6040516100d29190610a2e565b60405180910390f35b6100f560048036038101906100f09190610aa7565b61038d565b005b6100ff61052c565b60405161010c9190610ae3565b60405180910390f35b61011d610552565b005b610127610638565b6040516101349190610a04565b60405180910390f35b61014561063e565b6040516101529190610a2e565b60405180910390f35b610163610662565b6040516101709190610ae3565b60405180910390f35b60008060025460008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101d89190610ae3565b60206040518083038186803b1580156101f057600080fd5b505afa158015610204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102289190610b2a565b6102329190610b86565b90507f0000000000000000000000000000000000000000000000000000000062e7178067ffffffffffffffff168367ffffffffffffffff16101561027a576000915050610364565b7f0000000000000000000000000000000000000000000000000000000001e191407f0000000000000000000000000000000000000000000000000000000062e717806102c69190610bdc565b67ffffffffffffffff168367ffffffffffffffff1611156102ea5780915050610364565b7f0000000000000000000000000000000000000000000000000000000001e1914067ffffffffffffffff167f0000000000000000000000000000000000000000000000000000000062e71780846103419190610c1a565b67ffffffffffffffff16826103569190610c4e565b6103609190610cd7565b9150505b919050565b7f0000000000000000000000000000000000000000000000000000000001e1914081565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461041d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041490610d8b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561048d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048490610e1d565b60405180910390fd5b7f768099735d1c322a05a5b9d7b76d99682a1833d3f7055e5ede25e0f2eeaa8c6d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516104e0929190610e3d565b60405180910390a180600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060025461056042610179565b61056a9190610e66565b905060008111156106355780600260008282546105879190610b86565b925050819055507fc7798891864187665ac6dd119286e44ec13f014527aeeb2b8eb3fd413df9317960008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516105df929190610e9a565b60405180910390a161063460008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683610686565b5b50565b60025481565b7f0000000000000000000000000000000000000000000000000000000062e7178081565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6107078363a9059cbb60e01b84846040516024016106a5929190610e9a565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061070c565b505050565b600061076e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166107d39092919063ffffffff16565b90506000815111156107ce578080602001905181019061078e9190610efb565b6107cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107c490610f9a565b60405180910390fd5b5b505050565b60606107e284846000856107eb565b90509392505050565b606082471015610830576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108279061102c565b60405180910390fd5b610839856108ff565b610878576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086f90611098565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516108a19190611132565b60006040518083038185875af1925050503d80600081146108de576040519150601f19603f3d011682016040523d82523d6000602084013e6108e3565b606091505b50915091506108f3828286610912565b92505050949350505050565b600080823b905060008111915050919050565b6060831561092257829050610972565b6000835111156109355782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610969919061119e565b60405180910390fd5b9392505050565b600080fd5b600067ffffffffffffffff82169050919050565b61099b8161097e565b81146109a657600080fd5b50565b6000813590506109b881610992565b92915050565b6000602082840312156109d4576109d3610979565b5b60006109e2848285016109a9565b91505092915050565b6000819050919050565b6109fe816109eb565b82525050565b6000602082019050610a1960008301846109f5565b92915050565b610a288161097e565b82525050565b6000602082019050610a436000830184610a1f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610a7482610a49565b9050919050565b610a8481610a69565b8114610a8f57600080fd5b50565b600081359050610aa181610a7b565b92915050565b600060208284031215610abd57610abc610979565b5b6000610acb84828501610a92565b91505092915050565b610add81610a69565b82525050565b6000602082019050610af86000830184610ad4565b92915050565b610b07816109eb565b8114610b1257600080fd5b50565b600081519050610b2481610afe565b92915050565b600060208284031215610b4057610b3f610979565b5b6000610b4e84828501610b15565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610b91826109eb565b9150610b9c836109eb565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610bd157610bd0610b57565b5b828201905092915050565b6000610be78261097e565b9150610bf28361097e565b92508267ffffffffffffffff03821115610c0f57610c0e610b57565b5b828201905092915050565b6000610c258261097e565b9150610c308361097e565b925082821015610c4357610c42610b57565b5b828203905092915050565b6000610c59826109eb565b9150610c64836109eb565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610c9d57610c9c610b57565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000610ce2826109eb565b9150610ced836109eb565b925082610cfd57610cfc610ca8565b5b828204905092915050565b600082825260208201905092915050565b7f546f6b656e56657374696e6757616c6c65743a206f6e6c792062656e6566696360008201527f6961727900000000000000000000000000000000000000000000000000000000602082015250565b6000610d75602483610d08565b9150610d8082610d19565b604082019050919050565b60006020820190508181036000830152610da481610d68565b9050919050565b7f546f6b656e56657374696e6757616c6c65743a2062656e65666963696172792060008201527f6973207a65726f20616464726573730000000000000000000000000000000000602082015250565b6000610e07602f83610d08565b9150610e1282610dab565b604082019050919050565b60006020820190508181036000830152610e3681610dfa565b9050919050565b6000604082019050610e526000830185610ad4565b610e5f6020830184610ad4565b9392505050565b6000610e71826109eb565b9150610e7c836109eb565b925082821015610e8f57610e8e610b57565b5b828203905092915050565b6000604082019050610eaf6000830185610ad4565b610ebc60208301846109f5565b9392505050565b60008115159050919050565b610ed881610ec3565b8114610ee357600080fd5b50565b600081519050610ef581610ecf565b92915050565b600060208284031215610f1157610f10610979565b5b6000610f1f84828501610ee6565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000610f84602a83610d08565b9150610f8f82610f28565b604082019050919050565b60006020820190508181036000830152610fb381610f77565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000611016602683610d08565b915061102182610fba565b604082019050919050565b6000602082019050818103600083015261104581611009565b9050919050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000611082601d83610d08565b915061108d8261104c565b602082019050919050565b600060208201905081810360008301526110b181611075565b9050919050565b600081519050919050565b600081905092915050565b60005b838110156110ec5780820151818401526020810190506110d1565b838111156110fb576000848401525b50505050565b600061110c826110b8565b61111681856110c3565b93506111268185602086016110ce565b80840191505092915050565b600061113e8284611101565b915081905092915050565b600081519050919050565b6000601f19601f8301169050919050565b600061117082611149565b61117a8185610d08565b935061118a8185602086016110ce565b61119381611154565b840191505092915050565b600060208201905081810360008301526111b88184611165565b90509291505056fea2646970667358221220a8dd068167f6ae9e7665c1cd9167efc50234d36b0b2b0954bcdf79783f84d12a64736f6c63430008090033
[ 38 ]
0xf3cd95bca5a82d7418bce1f59dcd6aca346b4630
/* 🗡 Mashima Inu Pre Launch Information Update 🗡 FAQ: When will the website be up? ⁃ The website is currently live. https://mashimainu.com/ How much liquidity will be added for launch? ⁃ The team has decided to make this community driven and would want everyone to participate in the process. Momentarily a telegram poll to get feedback on how much ETH should be used for starting liquidity would be created and pinned soon. Options would be between 5-10ETH. How long will liquidity be locked? ⁃ 30 DAYS ( WITH AN EXTENSION FOR EVERY MARKETCAP MILESTONE) Will this be a stealth or fair launch? ⁃ It will be stealth and we’ll set a timeframe for the launch. Expected launch date will be announced in the next 24-36hrs. Will there be a presale? ⁃ No, but there might be a private sale for 10% of total supply geared towards strategic influencers/ partners. (The team is still considering this amongst other alternatives) Marketing plans? ⁃ Heavy marketing will be done pre- and post launch. Youtube, twitter, telegram and even discord servers will be targeted. ⁃ A referral contest to win 1 ETH in $MASHIMA upon launch would also be initiated as part of the marketing rollout expected to grow the community pre-launch. ( More Information would be provided soon) */ 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 Mashima 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 = 1000* 10**12* 10**18; string private _name = ' Mashima Inu '; string private _symbol = 'MASHIMA'; 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); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220ff23298a61ef648eadff0a96fbe38f681306882bfaf2233dd04b67df5d382c0a64736f6c634300060c0033
[ 38 ]
0xf3cdcd456e46087d76e7c1debcbeba8d46ea2f2a
// 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); } /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } /* * @dev 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 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 = 1000000000*(10**8); 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 8; } /** * @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 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"); unchecked { _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: * * - `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); } /** * @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); } /** * @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 { } function _initialTransfer(address from, address to, uint256 amount) internal { _balances[to] += amount; emit Transfer(from, to, amount); } } /** * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { uint256 immutable private _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor (uint256 cap_) ERC20("Climate Change Coin", "CLIMATE") { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; _initialTransfer(address(0), msg.sender, 1000000000*(10**8)); //_transfer(address(0), msg.sender, 1000000000*(10**8)); } /** * @dev Returns the cap on the token's total supply. */ function cap() public view virtual returns (uint256) { return _cap; } /** * @dev See {ERC20-_mint}. */ function _mint(address account, uint256 amount) internal virtual override { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } } contract ClimateChangeCoin is ERC20Capped{ constructor() ERC20Capped(1000000000*(10**8)){ } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80633950935111610071578063395093511461019157806370a08231146101c157806395d89b41146101f1578063a457c2d71461020f578063a9059cbb1461023f578063dd62ed3e1461026f576100b4565b806306fdde03146100b9578063095ea7b3146100d757806318160ddd1461010757806323b872dd14610125578063313ce56714610155578063355274ea14610173575b600080fd5b6100c161029f565b6040516100ce919061104b565b60405180910390f35b6100f160048036038101906100ec9190610cc4565b610331565b6040516100fe9190611030565b60405180910390f35b61010f61034f565b60405161011c919061114d565b60405180910390f35b61013f600480360381019061013a9190610c75565b610359565b60405161014c9190611030565b60405180910390f35b61015d610451565b60405161016a9190611168565b60405180910390f35b61017b61045a565b604051610188919061114d565b60405180910390f35b6101ab60048036038101906101a69190610cc4565b610482565b6040516101b89190611030565b60405180910390f35b6101db60048036038101906101d69190610c10565b61052e565b6040516101e8919061114d565b60405180910390f35b6101f9610576565b604051610206919061104b565b60405180910390f35b61022960048036038101906102249190610cc4565b610608565b6040516102369190611030565b60405180910390f35b61025960048036038101906102549190610cc4565b6106f3565b6040516102669190611030565b60405180910390f35b61028960048036038101906102849190610c39565b610711565b604051610296919061114d565b60405180910390f35b6060600380546102ae9061127d565b80601f01602080910402602001604051908101604052809291908181526020018280546102da9061127d565b80156103275780601f106102fc57610100808354040283529160200191610327565b820191906000526020600020905b81548152906001019060200180831161030a57829003601f168201915b5050505050905090565b600061034561033e610798565b84846107a0565b6001905092915050565b6000600254905090565b600061036684848461096b565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006103b1610798565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610431576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610428906110cd565b60405180910390fd5b6104458561043d610798565b8584036107a0565b60019150509392505050565b60006008905090565b60007f000000000000000000000000000000000000000000000000016345785d8a0000905090565b600061052461048f610798565b84846001600061049d610798565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461051f919061119f565b6107a0565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546105859061127d565b80601f01602080910402602001604051908101604052809291908181526020018280546105b19061127d565b80156105fe5780601f106105d3576101008083540402835291602001916105fe565b820191906000526020600020905b8154815290600101906020018083116105e157829003601f168201915b5050505050905090565b60008060016000610617610798565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156106d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106cb9061112d565b60405180910390fd5b6106e86106df610798565b858584036107a0565b600191505092915050565b6000610707610700610798565b848461096b565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610810576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108079061110d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610880576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108779061108d565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161095e919061114d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d2906110ed565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a429061106d565b60405180910390fd5b610a56838383610be1565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610adc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad3906110ad565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610b6f919061119f565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610bd3919061114d565b60405180910390a350505050565b505050565b600081359050610bf58161131e565b92915050565b600081359050610c0a81611335565b92915050565b600060208284031215610c2257600080fd5b6000610c3084828501610be6565b91505092915050565b60008060408385031215610c4c57600080fd5b6000610c5a85828601610be6565b9250506020610c6b85828601610be6565b9150509250929050565b600080600060608486031215610c8a57600080fd5b6000610c9886828701610be6565b9350506020610ca986828701610be6565b9250506040610cba86828701610bfb565b9150509250925092565b60008060408385031215610cd757600080fd5b6000610ce585828601610be6565b9250506020610cf685828601610bfb565b9150509250929050565b610d0981611207565b82525050565b6000610d1a82611183565b610d24818561118e565b9350610d3481856020860161124a565b610d3d8161130d565b840191505092915050565b6000610d5560238361118e565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610dbb60228361118e565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e2160268361118e565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610e8760288361118e565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610eed60258361118e565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610f5360248361118e565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000610fb960258361118e565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b61101b81611233565b82525050565b61102a8161123d565b82525050565b60006020820190506110456000830184610d00565b92915050565b600060208201905081810360008301526110658184610d0f565b905092915050565b6000602082019050818103600083015261108681610d48565b9050919050565b600060208201905081810360008301526110a681610dae565b9050919050565b600060208201905081810360008301526110c681610e14565b9050919050565b600060208201905081810360008301526110e681610e7a565b9050919050565b6000602082019050818103600083015261110681610ee0565b9050919050565b6000602082019050818103600083015261112681610f46565b9050919050565b6000602082019050818103600083015261114681610fac565b9050919050565b60006020820190506111626000830184611012565b92915050565b600060208201905061117d6000830184611021565b92915050565b600081519050919050565b600082825260208201905092915050565b60006111aa82611233565b91506111b583611233565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156111ea576111e96112af565b5b828201905092915050565b600061120082611213565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561126857808201518184015260208101905061124d565b83811115611277576000848401525b50505050565b6000600282049050600182168061129557607f821691505b602082108114156112a9576112a86112de565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b611327816111f5565b811461133257600080fd5b50565b61133e81611233565b811461134957600080fd5b5056fea26469706673582212208e86c6c8101b5f018275bd6ca0ab4ceabbb468eae0d150d7752ab3488499a2f664736f6c63430008000033
[ 38 ]
0xf3cefd8a3a00431fb652872e07b014898ff3ccd2
/** *Submitted for verification at Etherscan.io on 2021-02-02 */ /** *Submitted for verification at Etherscan.io on 2020-10-06 */ // Dependency file: contracts/interfaces/IMerkleDistributor.sol // pragma solidity ^0.6.10; // Allows anyone to claim a token if they exist in a merkle root. interface IMerkleDistributor { // Returns the address of the token distributed by this contract. function token() external view returns (address); // Returns the merkle root of the merkle tree containing account balances available to claim. function merkleRoot() external view returns (bytes32); // Returns true if the index has been marked claimed. function isClaimed(uint256 index) external view returns (bool); // Claim the given amount of the token to the given address. Reverts if the inputs are invalid. function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external; // This event is triggered whenever a call to #claim succeeds. event Claimed(uint256 index, address account, uint256 amount); } // Dependency file: @openzeppelin/contracts/cryptography/MerkleProof.sol // pragma solidity ^0.6.0; /** * @dev These functions deal with verification of Merkle trees (hash trees), */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol // pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * // importANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.6.10; // import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import { MerkleProof } from "@openzeppelin/contracts/cryptography/MerkleProof.sol"; // import { IMerkleDistributor } from "../interfaces/IMerkleDistributor.sol"; contract MerkleDistributor is IMerkleDistributor { address public immutable override token; bytes32 public immutable override merkleRoot; // This is a packed array of booleans. mapping(uint256 => uint256) private claimedBitMap; constructor(address token_, bytes32 merkleRoot_) public { token = token_; merkleRoot = merkleRoot_; } function isClaimed(uint256 index) public view override returns (bool) { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; uint256 claimedWord = claimedBitMap[claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(uint256 index) private { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex); } function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override { require(!isClaimed(index), "MerkleDistributor: Drop already claimed."); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, account, amount)); require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDistributor: Invalid proof."); // Mark it claimed and send the token. _setClaimed(index); require(IERC20(token).transfer(account, amount), "MerkleDistributor: Transfer failed."); emit Claimed(index, account, amount); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80632e7ba6ef146100515780632eb4a7ab146100df5780639e34070f146100f9578063fc0c546a1461012a575b600080fd5b6100dd6004803603608081101561006757600080fd5b8135916001600160a01b03602082013516916040820135919081019060808101606082013564010000000081111561009e57600080fd5b8201836020820111156100b057600080fd5b803590602001918460208302840111640100000000831117156100d257600080fd5b50909250905061014e565b005b6100e76103b1565b60408051918252519081900360200190f35b6101166004803603602081101561010f57600080fd5b50356103d5565b604080519115158252519081900360200190f35b6101326103fb565b604080516001600160a01b039092168252519081900360200190f35b610157856103d5565b156101935760405162461bcd60e51b81526004018080602001828103825260288152602001806104f06028913960400191505060405180910390fd5b6040805160208082018890526bffffffffffffffffffffffff19606088901b1682840152605480830187905283518084039091018152607483018085528151918301919091206094928602808501840190955285825293610236939192879287928392909101908490808284376000920191909152507f8d3b17d804d00e35f6f51e3cb8182c4caa14e8569d87d3d682d361da6cf639b1925085915061041f9050565b6102715760405162461bcd60e51b81526004018080602001828103825260218152602001806105186021913960400191505060405180910390fd5b61027a866104c8565b7f000000000000000000000000d46ac82b7ebb77ccb5d4eaf053710aaf6567def36001600160a01b031663a9059cbb86866040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156102fa57600080fd5b505af115801561030e573d6000803e3d6000fd5b505050506040513d602081101561032457600080fd5b50516103615760405162461bcd60e51b81526004018080602001828103825260238152602001806105396023913960400191505060405180910390fd5b604080518781526001600160a01b038716602082015280820186905290517f4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed0269181900360600190a1505050505050565b7f8d3b17d804d00e35f6f51e3cb8182c4caa14e8569d87d3d682d361da6cf639b181565b6101008104600090815260208190526040902054600160ff9092169190911b9081161490565b7f000000000000000000000000d46ac82b7ebb77ccb5d4eaf053710aaf6567def381565b600081815b85518110156104bd57600086828151811061043b57fe5b6020026020010151905080831161048257828160405160200180838152602001828152602001925050506040516020818303038152906040528051906020012092506104b4565b808360405160200180838152602001828152602001925050506040516020818303038152906040528051906020012092505b50600101610424565b509092149392505050565b610100810460009081526020819052604090208054600160ff9093169290921b909117905556fe4d65726b6c654469737472696275746f723a2044726f7020616c726561647920636c61696d65642e4d65726b6c654469737472696275746f723a20496e76616c69642070726f6f662e4d65726b6c654469737472696275746f723a205472616e73666572206661696c65642ea264697066735822122069bbd37af31a66218ead83f210becd2ef8dc9042b149f4990ef7f377324281a864736f6c634300060a0033
[ 38 ]
0xF3Cf23D8ab347B177a572A64f56ce49b012f28d3
pragma solidity >=0.4.22 <0.6.0; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; } contract TokenERC20 { // Public variables of the token string public name = "One Earth" ; string public symbol = "OEA"; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply = 400000000000 ; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * Initializes contract with initial supply tokens to the creator of the contract */ constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != address(0x0)); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value >= balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a08231146102b057806379cc67901461030857806395d89b411461036e578063a9059cbb146103f1578063cae9ca5114610457578063dd62ed3e14610554576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a257806323b872dd146101c0578063313ce5671461024657806342966c681461026a575b600080fd5b6100c16105cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061066a565b604051808215151515815260200191505060405180910390f35b6101aa61075c565b6040518082815260200191505060405180910390f35b61022c600480360360608110156101d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610762565b604051808215151515815260200191505060405180910390f35b61024e61088d565b604051808260ff1660ff16815260200191505060405180910390f35b6102966004803603602081101561028057600080fd5b81019080803590602001909291905050506108a0565b604051808215151515815260200191505060405180910390f35b6102f2600480360360208110156102c657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a2565b6040518082815260200191505060405180910390f35b6103546004803603604081101561031e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ba565b604051808215151515815260200191505060405180910390f35b610376610bd0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103b657808201518184015260208101905061039b565b50505050905090810190601f1680156103e35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61043d6004803603604081101561040757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c6e565b604051808215151515815260200191505060405180910390f35b61053a6004803603606081101561046d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156104b457600080fd5b8201836020820111156104c657600080fd5b803590602001918460018302840111640100000000831117156104e857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610c85565b604051808215151515815260200191505060405180910390f35b6105b66004803603604081101561056a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ded565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106625780601f1061063757610100808354040283529160200191610662565b820191906000526020600020905b81548152906001019060200180831161064557829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60035481565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156107ed57600080fd5b81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550610882848484610e12565b600190509392505050565b600260009054906101000a900460ff1681565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156108ee57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60046020528060005260406000206000915090505481565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610a0857600080fd5b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610a9157600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c665780601f10610c3b57610100808354040283529160200191610c66565b820191906000526020600020905b815481529060010190602001808311610c4957829003601f168201915b505050505081565b6000610c7b338484610e12565b6001905092915050565b600080849050610c95858561066a565b15610de4578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff1660e01b8152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610d73578082015181840152602081019050610d58565b50505050905090810190601f168015610da05780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015610dc257600080fd5b505af1158015610dd6573d6000803e3d6000fd5b505050506001915050610de6565b505b9392505050565b6005602052816000526040600020602052806000526040600020600091509150505481565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e4c57600080fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610e9857600080fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011015610f2557600080fd5b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401905081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011461113257fe5b5050505056fea265627a7a72315820c71855320f0896684fe75aef6e177166ed7101f3ea6d0eb7bba0eed25032664264736f6c63430005110032
[ 38 ]
0xf3cf29afd460f64b7aca367597651114325a119e
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); //go the white address first if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1461045492991056468287016484048686824852249628073)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610a77565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610e36565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e3b565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610e53565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610ef7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f95565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610faa565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611213565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611324565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073ffeb8bb8436cb28ac727e3f7371981d7de7fcda973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6109c257600080fd5b6000821115610a16576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ad957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610b365760019050610e2f565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610bf257600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610c88848484611349565b610c9157600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cdd57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eaf57600080fd5b60008311610ebe576000610ec6565b6012600a0a83025b60028190555060008211610edb576000610ee3565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b505050505081565b6000610fa2338484610b23565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100657600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561105a57600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112075760008582815181106110c457fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161117457fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816111e357fe5b046040518082815260200191505060405180910390a35080806001019150506110ad565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126d57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106112b85780518252602082019150602081019050602083039250611295565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611318576040519150601f19603f3d011682016040523d82523d6000602084013e61131d565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061137f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611585565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061142a5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806114745750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806114aa57508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115025750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115565750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561156557600191505061157e565b61156f8584611713565b61157857600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106115c45783856115c7565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561172857506000600254145b801561173657506000600354145b1561174457600090506117e3565b600060045411156117a0576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179f57600090506117e3565b5b600060025411156117bf578160025411156117be57600090506117e3565b5b600060035411156117de576003548211156117dd57600090506117e3565b5b600190505b9291505056fea265627a7a72315820efa7550cb11be365760ab35af3a30530b8a2df8acf3b0c3cd345230dd3fd8dbb64736f6c63430005110032
[ 15, 8 ]
0xf3cf4f251edbdbd18f1c75b3e087e80d902558ae
pragma solidity ^0.4.23; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } /** * @dev Allows the current owner to relinquish control of the contract. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } 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; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract FCoinTokenB is CappedToken, PausableToken { string public constant name = "FCoin Token B"; // solium-disable-line uppercase string public constant symbol = "FTB"; // solium-disable-line uppercase uint8 public constant decimals = 18; // solium-disable-line uppercase uint256 public constant INITIAL_SUPPLY = 10000000000000000000000000000; uint256 public constant MAX_SUPPLY = 100 * 10000 * 10000 * (10 ** uint256(decimals)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor() CappedToken(MAX_SUPPLY) public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint whenNotPaused public returns (bool) { return super.mint(_to, _amount); } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint whenNotPaused public returns (bool) { return super.finishMinting(); } /** * @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 whenNotPaused public { super.transferOwnership(newOwner); } /** * The fallback function. */ function() payable public { revert(); } }
0x6080604052600436106101325763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166305d2035b811461013757806306fdde0314610160578063095ea7b3146101ea57806318160ddd1461020e57806323b872dd146102355780632ff2e9dc1461025f578063313ce5671461027457806332cb6b0c1461025f578063355274ea1461029f5780633f4ba83a146102b457806340c10f19146102cb5780635c975abb146102ef578063661884631461030457806370a0823114610328578063715018a6146103495780637d64bcb41461035e5780638456cb59146103735780638da5cb5b1461038857806395d89b41146103b9578063a9059cbb146103ce578063d73dd623146103f2578063dd62ed3e14610416578063f2fde38b1461043d575b600080fd5b34801561014357600080fd5b5061014c61045e565b604080519115158252519081900360200190f35b34801561016c57600080fd5b5061017561046e565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101af578181015183820152602001610197565b50505050905090810190601f1680156101dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f657600080fd5b5061014c600160a060020a03600435166024356104a5565b34801561021a57600080fd5b506102236104c9565b60408051918252519081900360200190f35b34801561024157600080fd5b5061014c600160a060020a03600435811690602435166044356104cf565b34801561026b57600080fd5b506102236104f5565b34801561028057600080fd5b50610289610505565b6040805160ff9092168252519081900360200190f35b3480156102ab57600080fd5b5061022361050a565b3480156102c057600080fd5b506102c9610510565b005b3480156102d757600080fd5b5061014c600160a060020a036004351660243561056d565b3480156102fb57600080fd5b5061014c6105b8565b34801561031057600080fd5b5061014c600160a060020a03600435166024356105c1565b34801561033457600080fd5b50610223600160a060020a03600435166105de565b34801561035557600080fd5b506102c96105f9565b34801561036a57600080fd5b5061014c610667565b34801561037f57600080fd5b506102c96106b5565b34801561039457600080fd5b5061039d610714565b60408051600160a060020a039092168252519081900360200190f35b3480156103c557600080fd5b50610175610723565b3480156103da57600080fd5b5061014c600160a060020a036004351660243561075a565b3480156103fe57600080fd5b5061014c600160a060020a0360043516602435610777565b34801561042257600080fd5b50610223600160a060020a0360043581169060243516610794565b34801561044957600080fd5b506102c9600160a060020a03600435166107bf565b60035460a060020a900460ff1681565b60408051808201909152600d81527f46436f696e20546f6b656e204200000000000000000000000000000000000000602082015281565b60055460009060ff16156104b857600080fd5b6104c283836107f2565b9392505050565b60015490565b60055460009060ff16156104e257600080fd5b6104ed848484610858565b949350505050565b6b204fce5e3e2502611000000081565b601281565b60045481565b600354600160a060020a0316331461052757600080fd5b60055460ff16151561053857600080fd5b6005805460ff191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600354600090600160a060020a0316331461058757600080fd5b60035460a060020a900460ff161561059e57600080fd5b60055460ff16156105ae57600080fd5b6104c283836109cf565b60055460ff1681565b60055460009060ff16156105d457600080fd5b6104c28383610a2b565b600160a060020a031660009081526020819052604090205490565b600354600160a060020a0316331461061057600080fd5b600354604051600160a060020a03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a26003805473ffffffffffffffffffffffffffffffffffffffff19169055565b600354600090600160a060020a0316331461068157600080fd5b60035460a060020a900460ff161561069857600080fd5b60055460ff16156106a857600080fd5b6106b0610b1b565b905090565b600354600160a060020a031633146106cc57600080fd5b60055460ff16156106dc57600080fd5b6005805460ff191660011790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600354600160a060020a031681565b60408051808201909152600381527f4654420000000000000000000000000000000000000000000000000000000000602082015281565b60055460009060ff161561076d57600080fd5b6104c28383610b9f565b60055460009060ff161561078a57600080fd5b6104c28383610c80565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600354600160a060020a031633146107d657600080fd5b60055460ff16156107e657600080fd5b6107ef81610d19565b50565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b6000600160a060020a038316151561086f57600080fd5b600160a060020a03841660009081526020819052604090205482111561089457600080fd5b600160a060020a03841660009081526002602090815260408083203384529091529020548211156108c457600080fd5b600160a060020a0384166000908152602081905260409020546108ed908363ffffffff610dae16565b600160a060020a038086166000908152602081905260408082209390935590851681522054610922908363ffffffff610dc016565b600160a060020a03808516600090815260208181526040808320949094559187168152600282528281203382529091522054610964908363ffffffff610dae16565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b600354600090600160a060020a031633146109e957600080fd5b60035460a060020a900460ff1615610a0057600080fd5b600454600154610a16908463ffffffff610dc016565b1115610a2157600080fd5b6104c28383610dd3565b336000908152600260209081526040808320600160a060020a038616845290915281205480831115610a8057336000908152600260209081526040808320600160a060020a0388168452909152812055610ab5565b610a90818463ffffffff610dae16565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600354600090600160a060020a03163314610b3557600080fd5b60035460a060020a900460ff1615610b4c57600080fd5b6003805474ff0000000000000000000000000000000000000000191660a060020a1790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b6000600160a060020a0383161515610bb657600080fd5b33600090815260208190526040902054821115610bd257600080fd5b33600090815260208190526040902054610bf2908363ffffffff610dae16565b3360009081526020819052604080822092909255600160a060020a03851681522054610c24908363ffffffff610dc016565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610cb4908363ffffffff610dc016565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600354600160a060020a03163314610d3057600080fd5b600160a060020a0381161515610d4557600080fd5b600354604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610dba57fe5b50900390565b81810182811015610dcd57fe5b92915050565b600354600090600160a060020a03163314610ded57600080fd5b60035460a060020a900460ff1615610e0457600080fd5b600154610e17908363ffffffff610dc016565b600155600160a060020a038316600090815260208190526040902054610e43908363ffffffff610dc016565b600160a060020a03841660008181526020818152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a038516916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3506001929150505600a165627a7a72305820d9fb80b014b095eb7d65c33f998119c04657c2ffa1aba416625e099a844f028c0029
[ 2 ]
0xf3cf4f7fe12067df4b4b498e7f706c0f03944bb6
/** STARK Inu */ pragma solidity ^0.8.9; // SPDX-License-Identifier: Unlicensed interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } interface IAirdrop { function airdrop(address recipient, uint256 amount) external; } contract STARKINU is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private botWallets; bool botscantrade = false; bool public canTrade = false; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 10000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address public marketingWallet; string private _name = "Stark Inu"; string private _symbol = "STARK"; uint8 private _decimals = 9; uint256 public _taxFee = 1; uint256 private _previousTaxFee = _taxFee; uint256 public marketingFeePercent = 90; uint256 public _liquidityFee = 6; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 200000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 200000 * 10**9; uint256 public _maxWalletSize = 200000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function airdrop(address recipient, uint256 amount) external onlyOwner() { removeAllFee(); _transfer(_msgSender(), recipient, amount * 10**9); restoreAllFee(); } function airdropInternal(address recipient, uint256 amount) internal { removeAllFee(); _transfer(_msgSender(), recipient, amount); restoreAllFee(); } function airdropArray(address[] calldata newholders, uint256[] calldata amounts) external onlyOwner(){ uint256 iterator = 0; require(newholders.length == amounts.length, "must be the same length"); while(iterator < newholders.length){ airdropInternal(newholders[iterator], amounts[iterator] * 10**9); iterator += 1; } } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMarketingFeePercent(uint256 fee) public onlyOwner { marketingFeePercent = fee; } function setMarketingWallet(address walletAddress) public onlyOwner { marketingWallet = walletAddress; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { require(taxFee < 10, "Tax fee cannot be more than 10%"); _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function _setMaxWalletSizePercent(uint256 maxWalletSize) external onlyOwner { _maxWalletSize = _tTotal.mul(maxWalletSize).div(10**3); } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 200000, "Max Tx Amount cannot be less than 69 Million"); _maxTxAmount = maxTxAmount * 10**9; } function setSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() { require(SwapThresholdAmount > 200000, "Swap Threshold Amount cannot be less than 69 Million"); numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9; } function claimTokens () public onlyOwner { // make sure we capture all BNB that may or may not be sent to this contract payable(marketingWallet).transfer(address(this).balance); } function claimOtherTokens(IERC20 tokenAddress, address walletaddress) external onlyOwner() { tokenAddress.transfer(walletaddress, tokenAddress.balanceOf(address(this))); } function clearStuckBalance (address payable walletaddress) external onlyOwner() { walletaddress.transfer(address(this).balance); } function addBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = true; } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function allowtrading()external onlyOwner() { canTrade = true; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } if (takeFee) { if (to != uniswapV2Pair) { require( amount + balanceOf(to) <= _maxWalletSize, "Recipient exceeds max wallet size." ); } } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves // add the marketing wallet uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); uint256 marketingshare = newBalance.mul(marketingFeePercent).div(100); payable(marketingWallet).transfer(marketingshare); newBalance -= marketingshare; // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106103545760003560e01c806360d48489116101c6578063a6334231116100f7578063d4a3883f11610095578063dd62ed3e1161006f578063dd62ed3e146109dc578063ea2f0b3714610a22578063ec28438a14610a42578063f2fde38b14610a6257600080fd5b8063d4a3883f14610986578063da6fa55c146109a6578063dd467064146109bc57600080fd5b8063af2ce614116100d1578063af2ce6141461091b578063b6c523241461093b578063c49b9a8014610950578063d12a76881461097057600080fd5b8063a6334231146108d1578063a69df4b5146108e6578063a9059cbb146108fb57600080fd5b806388f82020116101645780638ee88c531161013e5780638ee88c53146108665780638f9a55c01461088657806395d89b411461089c578063a457c2d7146108b157600080fd5b806388f82020146107ef5780638ba4cc3c146108285780638da5cb5b1461084857600080fd5b8063715018a6116101a0578063715018a61461078457806375f0a87414610799578063764d72bf146107b95780637d1db4a5146107d957600080fd5b806360d48489146107155780636bc87c3a1461074e57806370a082311461076457600080fd5b80633685d419116102a0578063457c194c1161023e5780634a74bb02116102185780634a74bb021461067d57806352390c021461069c5780635342acb4146106bc5780635d098b38146106f557600080fd5b8063457c194c1461061457806348c54b9d1461063457806349bd5a5e1461064957600080fd5b80633b124fe71161027a5780633b124fe71461059e5780633bd5d173146105b4578063437823ec146105d45780634549b039146105f457600080fd5b80633685d4191461053e578063395093511461055e5780633ae7dc201461057e57600080fd5b806318160ddd1161030d5780632a360631116102e75780632a360631146104bd5780632d838119146104dd5780632f05205c146104fd578063313ce5671461051c57600080fd5b806318160ddd1461046857806323b872dd1461047d57806329e04b4a1461049d57600080fd5b80630305caff14610360578063061c82d01461038257806306fdde03146103a2578063095ea7b3146103cd57806313114a9d146103fd5780631694505e1461041c57600080fd5b3661035b57005b600080fd5b34801561036c57600080fd5b5061038061037b366004612f06565b610a82565b005b34801561038e57600080fd5b5061038061039d366004612f23565b610ad6565b3480156103ae57600080fd5b506103b7610b55565b6040516103c49190612f3c565b60405180910390f35b3480156103d957600080fd5b506103ed6103e8366004612f91565b610be7565b60405190151581526020016103c4565b34801561040957600080fd5b50600d545b6040519081526020016103c4565b34801561042857600080fd5b506104507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103c4565b34801561047457600080fd5b50600b5461040e565b34801561048957600080fd5b506103ed610498366004612fbd565b610bfe565b3480156104a957600080fd5b506103806104b8366004612f23565b610c67565b3480156104c957600080fd5b506103806104d8366004612f06565b610d14565b3480156104e957600080fd5b5061040e6104f8366004612f23565b610d62565b34801561050957600080fd5b50600a546103ed90610100900460ff1681565b34801561052857600080fd5b5060115460405160ff90911681526020016103c4565b34801561054a57600080fd5b50610380610559366004612f06565b610de6565b34801561056a57600080fd5b506103ed610579366004612f91565b610f9d565b34801561058a57600080fd5b50610380610599366004612ffe565b610fd3565b3480156105aa57600080fd5b5061040e60125481565b3480156105c057600080fd5b506103806105cf366004612f23565b611101565b3480156105e057600080fd5b506103806105ef366004612f06565b6111eb565b34801561060057600080fd5b5061040e61060f366004613045565b611239565b34801561062057600080fd5b5061038061062f366004612f23565b6112c6565b34801561064057600080fd5b506103806112f5565b34801561065557600080fd5b506104507f00000000000000000000000035179334951a1ba4127282f4f9a6f5b5bd71570381565b34801561068957600080fd5b506017546103ed90610100900460ff1681565b3480156106a857600080fd5b506103806106b7366004612f06565b61135b565b3480156106c857600080fd5b506103ed6106d7366004612f06565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561070157600080fd5b50610380610710366004612f06565b6114ae565b34801561072157600080fd5b506103ed610730366004612f06565b6001600160a01b031660009081526009602052604090205460ff1690565b34801561075a57600080fd5b5061040e60155481565b34801561077057600080fd5b5061040e61077f366004612f06565b6114fa565b34801561079057600080fd5b50610380611559565b3480156107a557600080fd5b50600e54610450906001600160a01b031681565b3480156107c557600080fd5b506103806107d4366004612f06565b6115bb565b3480156107e557600080fd5b5061040e60185481565b3480156107fb57600080fd5b506103ed61080a366004612f06565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561083457600080fd5b50610380610843366004612f91565b61161a565b34801561085457600080fd5b506000546001600160a01b0316610450565b34801561087257600080fd5b50610380610881366004612f23565b611675565b34801561089257600080fd5b5061040e601a5481565b3480156108a857600080fd5b506103b76116a4565b3480156108bd57600080fd5b506103ed6108cc366004612f91565b6116b3565b3480156108dd57600080fd5b50610380611702565b3480156108f257600080fd5b5061038061173d565b34801561090757600080fd5b506103ed610916366004612f91565b611843565b34801561092757600080fd5b50610380610936366004612f23565b611850565b34801561094757600080fd5b5060025461040e565b34801561095c57600080fd5b5061038061096b36600461306a565b6118a1565b34801561097c57600080fd5b5061040e60195481565b34801561099257600080fd5b506103806109a13660046130d3565b61191f565b3480156109b257600080fd5b5061040e60145481565b3480156109c857600080fd5b506103806109d7366004612f23565b611a12565b3480156109e857600080fd5b5061040e6109f7366004612ffe565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b348015610a2e57600080fd5b50610380610a3d366004612f06565b611a97565b348015610a4e57600080fd5b50610380610a5d366004612f23565b611ae2565b348015610a6e57600080fd5b50610380610a7d366004612f06565b611b87565b6000546001600160a01b03163314610ab55760405162461bcd60e51b8152600401610aac9061313f565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6000546001600160a01b03163314610b005760405162461bcd60e51b8152600401610aac9061313f565b600a8110610b505760405162461bcd60e51b815260206004820152601f60248201527f546178206665652063616e6e6f74206265206d6f7265207468616e20313025006044820152606401610aac565b601255565b6060600f8054610b6490613174565b80601f0160208091040260200160405190810160405280929190818152602001828054610b9090613174565b8015610bdd5780601f10610bb257610100808354040283529160200191610bdd565b820191906000526020600020905b815481529060010190602001808311610bc057829003601f168201915b5050505050905090565b6000610bf4338484611c5f565b5060015b92915050565b6000610c0b848484611d83565b610c5d8433610c588560405180606001604052806028815260200161336f602891396001600160a01b038a16600090815260056020908152604080832033845290915290205491906120e2565b611c5f565b5060019392505050565b6000546001600160a01b03163314610c915760405162461bcd60e51b8152600401610aac9061313f565b62030d408111610d005760405162461bcd60e51b815260206004820152603460248201527f53776170205468726573686f6c6420416d6f756e742063616e6e6f74206265206044820152733632b9b9903a3430b7101b1c9026b4b63634b7b760611b6064820152608401610aac565b610d0e81633b9aca006131c5565b60195550565b6000546001600160a01b03163314610d3e5760405162461bcd60e51b8152600401610aac9061313f565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000600c54821115610dc95760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610aac565b6000610dd361211c565b9050610ddf838261213f565b9392505050565b6000546001600160a01b03163314610e105760405162461bcd60e51b8152600401610aac9061313f565b6001600160a01b03811660009081526007602052604090205460ff16610e785760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610aac565b60005b600854811015610f9957816001600160a01b031660088281548110610ea257610ea26131e4565b6000918252602090912001546001600160a01b03161415610f875760088054610ecd906001906131fa565b81548110610edd57610edd6131e4565b600091825260209091200154600880546001600160a01b039092169183908110610f0957610f096131e4565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610f6157610f61613211565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610f9181613227565b915050610e7b565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610bf4918590610c589086612181565b6000546001600160a01b03163314610ffd5760405162461bcd60e51b8152600401610aac9061313f565b6040516370a0823160e01b81523060048201526001600160a01b0383169063a9059cbb90839083906370a082319060240160206040518083038186803b15801561104657600080fd5b505afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e9190613242565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b1580156110c457600080fd5b505af11580156110d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110fc919061325b565b505050565b3360008181526007602052604090205460ff16156111765760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610aac565b6000611181836121e0565b505050506001600160a01b0384166000908152600360205260409020549192506111ad9190508261222f565b6001600160a01b038316600090815260036020526040902055600c546111d3908261222f565b600c55600d546111e39084612181565b600d55505050565b6000546001600160a01b031633146112155760405162461bcd60e51b8152600401610aac9061313f565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b5483111561128d5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610aac565b816112ac57600061129d846121e0565b50939550610bf8945050505050565b60006112b7846121e0565b50929550610bf8945050505050565b6000546001600160a01b031633146112f05760405162461bcd60e51b8152600401610aac9061313f565b601455565b6000546001600160a01b0316331461131f5760405162461bcd60e51b8152600401610aac9061313f565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611358573d6000803e3d6000fd5b50565b6000546001600160a01b031633146113855760405162461bcd60e51b8152600401610aac9061313f565b6001600160a01b03811660009081526007602052604090205460ff16156113ee5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610aac565b6001600160a01b03811660009081526003602052604090205415611448576001600160a01b03811660009081526003602052604090205461142e90610d62565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b031633146114d85760405162461bcd60e51b8152600401610aac9061313f565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526007602052604081205460ff161561153757506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610bf890610d62565b6000546001600160a01b031633146115835760405162461bcd60e51b8152600401610aac9061313f565b600080546040516001600160a01b0390911690600080516020613397833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146115e55760405162461bcd60e51b8152600401610aac9061313f565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610f99573d6000803e3d6000fd5b6000546001600160a01b031633146116445760405162461bcd60e51b8152600401610aac9061313f565b61164c612271565b611664338361165f84633b9aca006131c5565b611d83565b610f99601354601255601654601555565b6000546001600160a01b0316331461169f5760405162461bcd60e51b8152600401610aac9061313f565b601555565b606060108054610b6490613174565b6000610bf43384610c58856040518060600160405280602581526020016133b7602591393360009081526005602090815260408083206001600160a01b038d16845290915290205491906120e2565b6000546001600160a01b0316331461172c5760405162461bcd60e51b8152600401610aac9061313f565b600a805461ff001916610100179055565b6001546001600160a01b031633146117a35760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610aac565b60025442116117f45760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610aac565b600154600080546040516001600160a01b03938416939091169160008051602061339783398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610bf4338484611d83565b6000546001600160a01b0316331461187a5760405162461bcd60e51b8152600401610aac9061313f565b61189b6103e861189583600b5461229f90919063ffffffff16565b9061213f565b601a5550565b6000546001600160a01b031633146118cb5760405162461bcd60e51b8152600401610aac9061313f565b601780548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061191490831515815260200190565b60405180910390a150565b6000546001600160a01b031633146119495760405162461bcd60e51b8152600401610aac9061313f565b600083821461199a5760405162461bcd60e51b815260206004820152601760248201527f6d757374206265207468652073616d65206c656e6774680000000000000000006044820152606401610aac565b83811015611a0b576119f98585838181106119b7576119b76131e4565b90506020020160208101906119cc9190612f06565b8484848181106119de576119de6131e4565b90506020020135633b9aca006119f491906131c5565b61231e565b611a04600182613278565b905061199a565b5050505050565b6000546001600160a01b03163314611a3c5760405162461bcd60e51b8152600401610aac9061313f565b60008054600180546001600160a01b03199081166001600160a01b03841617909155169055611a6b8142613278565b600255600080546040516001600160a01b0390911690600080516020613397833981519152908390a350565b6000546001600160a01b03163314611ac15760405162461bcd60e51b8152600401610aac9061313f565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b03163314611b0c5760405162461bcd60e51b8152600401610aac9061313f565b62030d408111611b735760405162461bcd60e51b815260206004820152602c60248201527f4d617820547820416d6f756e742063616e6e6f74206265206c6573732074686160448201526b37101b1c9026b4b63634b7b760a11b6064820152608401610aac565b611b8181633b9aca006131c5565b60185550565b6000546001600160a01b03163314611bb15760405162461bcd60e51b8152600401610aac9061313f565b6001600160a01b038116611c165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610aac565b600080546040516001600160a01b038085169392169160008051602061339783398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316611cc15760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610aac565b6001600160a01b038216611d225760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610aac565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611de75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610aac565b6001600160a01b038216611e495760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610aac565b60008111611eab5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610aac565b6000546001600160a01b03848116911614801590611ed757506000546001600160a01b03838116911614155b15611f3f57601854811115611f3f5760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610aac565b6000611f4a306114fa565b90506018548110611f5a57506018545b60195481108015908190611f71575060175460ff16155b8015611faf57507f00000000000000000000000035179334951a1ba4127282f4f9a6f5b5bd7157036001600160a01b0316856001600160a01b031614155b8015611fc25750601754610100900460ff165b15611fd5576019549150611fd582612331565b6001600160a01b03851660009081526006602052604090205460019060ff168061201757506001600160a01b03851660009081526006602052604090205460ff165b15612020575060005b80156120ce577f00000000000000000000000035179334951a1ba4127282f4f9a6f5b5bd7157036001600160a01b0316856001600160a01b0316146120ce57601a5461206b866114fa565b6120759086613278565b11156120ce5760405162461bcd60e51b815260206004820152602260248201527f526563697069656e742065786365656473206d61782077616c6c65742073697a604482015261329760f11b6064820152608401610aac565b6120da86868684612434565b505050505050565b600081848411156121065760405162461bcd60e51b8152600401610aac9190612f3c565b50600061211384866131fa565b95945050505050565b6000806000612129612670565b9092509050612138828261213f565b9250505090565b6000610ddf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506127f2565b60008061218e8385613278565b905083811015610ddf5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610aac565b60008060008060008060008060006121f78a612820565b92509250925060008060006122158d868661221061211c565b612862565b919f909e50909c50959a5093985091965092945050505050565b6000610ddf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506120e2565b6012541580156122815750601554155b1561228857565b601280546013556015805460165560009182905555565b6000826122ae57506000610bf8565b60006122ba83856131c5565b9050826122c78583613290565b14610ddf5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610aac565b612326612271565b611664338383611d83565b6017805460ff19166001179055600061234b82600261213f565b90506000612359838361222f565b905047612365836128b2565b6000612371478361222f565b9050600061238f60646118956014548561229f90919063ffffffff16565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f193505050501580156123ca573d6000803e3d6000fd5b506123d581836131fa565b91506123e18483612a79565b60408051868152602081018490529081018590527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506017805460ff1916905550505050565b600a54610100900460ff1661245d576000546001600160a01b0385811691161461245d57600080fd5b6001600160a01b03841660009081526009602052604090205460ff168061249c57506001600160a01b03831660009081526009602052604090205460ff165b156124f357600a5460ff166124f35760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610aac565b8061250057612500612271565b6001600160a01b03841660009081526007602052604090205460ff16801561254157506001600160a01b03831660009081526007602052604090205460ff16155b1561255657612551848484612b87565b612654565b6001600160a01b03841660009081526007602052604090205460ff1615801561259757506001600160a01b03831660009081526007602052604090205460ff165b156125a757612551848484612cad565b6001600160a01b03841660009081526007602052604090205460ff161580156125e957506001600160a01b03831660009081526007602052604090205460ff16155b156125f957612551848484612d56565b6001600160a01b03841660009081526007602052604090205460ff16801561263957506001600160a01b03831660009081526007602052604090205460ff165b1561264957612551848484612d9a565b612654848484612d56565b8061266a5761266a601354601255601654601555565b50505050565b600c54600b546000918291825b6008548110156127c25782600360006008848154811061269f5761269f6131e4565b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061270a57508160046000600884815481106126e3576126e36131e4565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561272057600c54600b54945094505050509091565b612766600360006008848154811061273a5761273a6131e4565b60009182526020808320909101546001600160a01b03168352820192909252604001902054849061222f565b92506127ae6004600060088481548110612782576127826131e4565b60009182526020808320909101546001600160a01b03168352820192909252604001902054839061222f565b9150806127ba81613227565b91505061267d565b50600b54600c546127d29161213f565b8210156127e957600c54600b549350935050509091565b90939092509050565b600081836128135760405162461bcd60e51b8152600401610aac9190612f3c565b5060006121138486613290565b60008060008061282f85612e0d565b9050600061283c86612e29565b905060006128548261284e898661222f565b9061222f565b979296509094509092505050565b6000808080612871888661229f565b9050600061287f888761229f565b9050600061288d888861229f565b9050600061289f8261284e868661222f565b939b939a50919850919650505050505050565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106128e7576128e76131e4565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561296057600080fd5b505afa158015612974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299891906132b2565b816001815181106129ab576129ab6131e4565b60200260200101906001600160a01b031690816001600160a01b0316815250506129f6307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c5f565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612a4b9085906000908690309042906004016132cf565b600060405180830381600087803b158015612a6557600080fd5b505af11580156120da573d6000803e3d6000fd5b612aa4307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c5f565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d719823085600080612aeb6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015612b4e57600080fd5b505af1158015612b62573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a0b9190613340565b600080600080600080612b99876121e0565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612bcb908861222f565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612bfa908761222f565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612c299086612181565b6001600160a01b038916600090815260036020526040902055612c4b81612e45565b612c558483612ecd565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612c9a91815260200190565b60405180910390a3505050505050505050565b600080600080600080612cbf876121e0565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612cf1908761222f565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612d279084612181565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612c299086612181565b600080600080600080612d68876121e0565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612bfa908761222f565b600080600080600080612dac876121e0565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612dde908861222f565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612cf1908761222f565b6000610bf860646118956012548561229f90919063ffffffff16565b6000610bf860646118956015548561229f90919063ffffffff16565b6000612e4f61211c565b90506000612e5d838361229f565b30600090815260036020526040902054909150612e7a9082612181565b3060009081526003602090815260408083209390935560079052205460ff16156110fc5730600090815260046020526040902054612eb89084612181565b30600090815260046020526040902055505050565b600c54612eda908361222f565b600c55600d54612eea9082612181565b600d555050565b6001600160a01b038116811461135857600080fd5b600060208284031215612f1857600080fd5b8135610ddf81612ef1565b600060208284031215612f3557600080fd5b5035919050565b600060208083528351808285015260005b81811015612f6957858101830151858201604001528201612f4d565b81811115612f7b576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612fa457600080fd5b8235612faf81612ef1565b946020939093013593505050565b600080600060608486031215612fd257600080fd5b8335612fdd81612ef1565b92506020840135612fed81612ef1565b929592945050506040919091013590565b6000806040838503121561301157600080fd5b823561301c81612ef1565b9150602083013561302c81612ef1565b809150509250929050565b801515811461135857600080fd5b6000806040838503121561305857600080fd5b82359150602083013561302c81613037565b60006020828403121561307c57600080fd5b8135610ddf81613037565b60008083601f84011261309957600080fd5b50813567ffffffffffffffff8111156130b157600080fd5b6020830191508360208260051b85010111156130cc57600080fd5b9250929050565b600080600080604085870312156130e957600080fd5b843567ffffffffffffffff8082111561310157600080fd5b61310d88838901613087565b9096509450602087013591508082111561312657600080fd5b5061313387828801613087565b95989497509550505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c9082168061318857607f821691505b602082108114156131a957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156131df576131df6131af565b500290565b634e487b7160e01b600052603260045260246000fd5b60008282101561320c5761320c6131af565b500390565b634e487b7160e01b600052603160045260246000fd5b600060001982141561323b5761323b6131af565b5060010190565b60006020828403121561325457600080fd5b5051919050565b60006020828403121561326d57600080fd5b8151610ddf81613037565b6000821982111561328b5761328b6131af565b500190565b6000826132ad57634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156132c457600080fd5b8151610ddf81612ef1565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561331f5784516001600160a01b0316835293830193918301916001016132fa565b50506001600160a01b03969096166060850152505050608001529392505050565b60008060006060848603121561335557600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212201ea0e68e2e9d27e8f0815501d4512aefda0efc7ab225bfb62fe1f1f6a7c6862d64736f6c63430008090033
[ 13, 16, 5 ]
0xf3cf928769470c43fa54b0ff4ce05b5ddd97dc37
pragma solidity ^0.4.25; pragma experimental "v0.5.0"; pragma experimental ABIEncoderV2; contract ERC20 { function transferFrom (address from, address to, uint256 value) public returns (bool); } contract SpecialCampaign { address public owner; address public rcv; uint256 constant public fstPerWei = 3000; uint256 constant private min = 0; uint256 constant private max = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; ERC20 public FST; address public fstCentral; bytes32 public sh; bool public finalized = false; event RCVDeclare (address rcv); event Finalize (uint256 fstkReceivedEtherWei, uint256 rcvReceivedFSTWei); struct Bonus { uint256 gte; uint256 lt; uint256 bonusPercentage; } Bonus[] public bonusArray; constructor (ERC20 _FST, address _fstCentral, bytes32 _secretHash) public { owner = msg.sender; rcv = address(0); bonusArray.push(Bonus( min, 300 ether, 0)); bonusArray.push(Bonus( 300 ether, 900 ether, 120)); bonusArray.push(Bonus( 900 ether, 1500 ether, 128)); bonusArray.push(Bonus(1500 ether, max, 132)); FST = _FST; fstCentral = _fstCentral; sh = _secretHash; } // Epoch timestamp: 1538323201 // Timestamp in milliseconds: 1538323201000 // Human time (GMT): Sunday, September 30, 2018 4:00:01 PM // Human time (your time zone): Monday, October 1, 2018 12:00:01 AM GMT+08:00 function () external payable { require(now <= 1538323201); } function declareRCV(string _secret) public { require( sh == keccak256(abi.encodePacked(_secret)) && rcv == address(0) ); rcv = msg.sender; emit RCVDeclare(rcv); } function finalize () public { require( msg.sender == owner && rcv != address(0) && now > 1538323201 && finalized == false ); finalized = true; uint256 fstkReceivedEtherWei = address(this).balance; uint256 rcvReceivedFSTWei = 0; // rollback if (fstkReceivedEtherWei < 300 ether) { rcv.transfer(fstkReceivedEtherWei); emit Finalize(0, 0); return; } for (uint8 i = 0; i < bonusArray.length; i++) { Bonus storage b = bonusArray[i]; if (fstkReceivedEtherWei >= b.gte && fstkReceivedEtherWei < b.lt) { rcvReceivedFSTWei = fstkReceivedEtherWei * b.bonusPercentage * fstPerWei / 100; } } require(FST.transferFrom(fstCentral, rcv, rcvReceivedFSTWei)); fstCentral.transfer(fstkReceivedEtherWei); emit Finalize(fstkReceivedEtherWei, rcvReceivedFSTWei); } }
0x6080604052600436106100a35763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663068839a281146100b6578063202920ef146100ee57806321ac64af146101105780632c0ef0041461013057806337e82226146101525780634bb278f3146101675780638da5cb5b1461017c5780639cd091251461019e578063b3f05b97146101b3578063d8c233d2146101d5575b635bb0f3014211156100b457600080fd5b005b3480156100c257600080fd5b506100d66100d1366004610829565b6101ea565b6040516100e593929190610916565b60405180910390f35b3480156100fa57600080fd5b5061010361021b565b6040516100e591906108d2565b34801561011c57600080fd5b506100b461012b3660046107f4565b610237565b34801561013c57600080fd5b50610145610405565b6040516100e591906108c4565b34801561015e57600080fd5b5061014561040b565b34801561017357600080fd5b506100b4610411565b34801561018857600080fd5b506101916106fe565b6040516100e5919061087a565b3480156101aa57600080fd5b5061019161071a565b3480156101bf57600080fd5b506101c8610736565b6040516100e591906108b6565b3480156101e157600080fd5b5061019161073f565b60068054829081106101f857fe5b600091825260209091206003909102018054600182015460029092015490925083565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b806040516020018082805190602001908083835b6020831061028857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161024b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831061030957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016102cc565b5181516020939093036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990911692169190911790526040519201829003909120600454149250508115905061037b575060015473ffffffffffffffffffffffffffffffffffffffff16155b151561038657600080fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317908190556040517f2950524bdce679f797c18b0d75b4ad790119e8d788e18268f564506d3f4eef23916103fa9173ffffffffffffffffffffffffffffffffffffffff919091169061087a565b60405180910390a150565b60045481565b610bb881565b6000805481908190819073ffffffffffffffffffffffffffffffffffffffff1633148015610456575060015473ffffffffffffffffffffffffffffffffffffffff1615155b80156104655750635bb0f30142115b8015610474575060055460ff16155b151561047f57600080fd5b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790553031935060009250681043561a882930000084101561054a5760015460405173ffffffffffffffffffffffffffffffffffffffff9091169085156108fc029086906000818181858888f1935050505015801561050a573d6000803e3d6000fd5b507f9d3cb3e4bff976f636db6ed472093505eb1b5bafc234ea8276ae83b3ea0a8b7460008060405161053d9291906108e0565b60405180910390a16106f8565b600091505b60065460ff831610156105b6576006805460ff841690811061056d57fe5b90600052602060002090600302019050806000015484101580156105945750806001015484105b156105ab5760028101546064908502610bb8020492505b60019091019061054f565b6002546003546001546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff938416936323b872dd936106199390821692911690889060040161088e565b602060405180830381600087803b15801561063357600080fd5b505af1158015610647573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061066b91908101906107ce565b151561067657600080fd5b60035460405173ffffffffffffffffffffffffffffffffffffffff9091169085156108fc029086906000818181858888f193505050501580156106bd573d6000803e3d6000fd5b507f9d3cb3e4bff976f636db6ed472093505eb1b5bafc234ea8276ae83b3ea0a8b7484846040516106ef9291906108fb565b60405180910390a15b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60055460ff1681565b60035473ffffffffffffffffffffffffffffffffffffffff1681565b600061076782516109b7565b9392505050565b6000601f8201831361077f57600080fd5b813561079261078d82610958565b610931565b915080825260208301602083018583830111156107ae57600080fd5b6107b98382846109d5565b50505092915050565b600061076782356109bc565b6000602082840312156107e057600080fd5b60006107ec848461075b565b949350505050565b60006020828403121561080657600080fd5b813567ffffffffffffffff81111561081d57600080fd5b6107ec8482850161076e565b60006020828403121561083b57600080fd5b60006107ec84846107c2565b6108508161099e565b82525050565b610850816109b7565b610850816109bc565b610850816109bf565b610850816109ca565b602081016108888284610847565b92915050565b6060810161089c8286610847565b6108a96020830185610847565b6107ec604083018461085f565b602081016108888284610856565b60208101610888828461085f565b602081016108888284610868565b604081016108ee8285610871565b6107676020830184610871565b60408101610909828561085f565b610767602083018461085f565b60608101610924828661085f565b6108a9602083018561085f565b60405181810167ffffffffffffffff8111828210171561095057600080fd5b604052919050565b600067ffffffffffffffff82111561096f57600080fd5b506020601f919091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160190565b73ffffffffffffffffffffffffffffffffffffffff1690565b151590565b90565b60006108888261099e565b6000610888826109bc565b828183375060009101525600a265627a7a72305820634ab93ce1db5ff9b29714b135e9bb282012cea7f63d6b6358ce66a30c2c63166c6578706572696d656e74616cf50037
[ 38 ]
0xF3cfb35afdbFFeA20892488bA7F1574AddA81B9D
pragma solidity ^0.4.21; /* * One Proof (Proof) * https://oneproof.net * * Instead of having many small "proof of" smart contracts here you can * re-brand a unique website and use this same smart contract address. * This would benefit all those holding because of the increased volume. * * * * * Features: * [✓] 5% rewards for token purchase, shared among all token holders. * [✓] 5% rewards for token selling, shared among all token holders. * [✓] 0% rewards for token transfer. * [✓] 3% rewards is given to referrer which is 60% of the 5% purchase reward. * [✓] Price increment by 0.000000001 instead of 0.00000001 for lower buy/sell price. * [✓] 1 token to activate Masternode referrals. * [✓] Ability to create games and other contracts that transact in One Proof Tokens. * [✓] No Administrators or Ambassadors that can change anything with the contract. * */ /** * Definition of contract accepting One Proof Tokens * Other contracts can reuse the AcceptsProof contract below to support One Proof Tokens */ contract AcceptsProof { Proof public tokenContract; function AcceptsProof(address _tokenContract) public { tokenContract = Proof(_tokenContract); } modifier onlyTokenContract { require(msg.sender == address(tokenContract)); _; } /** * @dev Standard ERC677 function that will handle incoming token transfers. * * @param _from Token sender address. * @param _value Amount of tokens. * @param _data Transaction metadata. */ function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool); } contract Proof { /*================================= = MODIFIERS = =================================*/ /// @dev Only people with tokens modifier onlyBagholders { require(myTokens() > 0); _; } /// @dev Only people with profits modifier onlyStronghands { require(myDividends(true) > 0); _; } modifier notContract() { require (msg.sender == tx.origin); _; } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy, uint timestamp, uint256 price ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned, uint timestamp, uint256 price ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "One Proof"; string public symbol = "Proof"; uint8 constant public decimals = 18; /// @dev 5% rewards for token purchase uint8 constant internal entryFee_ = 5; /// @dev 5% rewards for token selling uint8 constant internal exitFee_ = 5; /// @dev 60% of entryFee_ (i.e. 3% rewards) is given to referrer uint8 constant internal refferalFee_ = 60; uint256 constant internal tokenPriceInitial_ = 0.00000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether; uint256 constant internal magnitude = 2 ** 64; /// @dev proof of stake just 1 token) uint256 public stakingRequirement = 1e18; /*================================= = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_; uint256 internal profitPerShare_; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /// @dev Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) function buy(address _referredBy) public payable returns (uint256) { purchaseInternal(msg.value, _referredBy); } /** * @dev Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseInternal(msg.value, 0x0); } /// @dev Converts all of caller's dividends to tokens. function reinvest() onlyStronghands public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event emit onReinvestment(_customerAddress, _dividends, _tokens); } /// @dev Alias of sell() and withdraw(). function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /// @dev Withdraws all of the callers earnings. function withdraw() onlyStronghands public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event emit onWithdraw(_customerAddress, _dividends); } /// @dev Liquifies tokens to ethereum. function sell(uint256 _amountOfTokens) onlyBagholders public { // setup data address _customerAddress = msg.sender; // require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update rewards tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice()); } /** * Transfer tokens from the caller to a new holder. * No fee with this transfer */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens); // fire event emit Transfer(_customerAddress, _toAddress, _amountOfTokens); // ERC20 return true; } /** * Transfer token to a specified address and forward the data to recipient * ERC-677 standard * https://github.com/ethereum/EIPs/issues/677 * @param _to Receiver address. * @param _value Amount of tokens that will be transferred. * @param _data Transaction metadata. */ function transferAndCall(address _to, uint256 _value, bytes _data) external returns (bool) { require(_to != address(0)); require(transfer(_to, _value)); // do a normal token transfer to the contract if (isContract(_to)) { AcceptsProof receiver = AcceptsProof(_to); require(receiver.tokenFallback(msg.sender, _value, _data)); } return true; } /** * Additional check that the game address we are sending tokens to is a contract * assemble the given address bytecode. If bytecode exists then the _addr is a contract. */ function isContract(address _addr) private constant returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } /*===================================== = HELPERS AND CALCULATORS = =====================================*/ /** * @dev Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns (uint256) { return address(this).balance; } /// @dev Retrieve the total token supply. function totalSupply() public view returns (uint256) { return tokenSupply_; } /// @dev Retrieve the tokens owned by the caller. function myTokens() public view returns (uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * @dev Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns (uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /// @dev Retrieve the token balance of any single address. function balanceOf(address _customerAddress) public view returns (uint256) { return tokenBalanceLedger_[_customerAddress]; } /// @dev Retrieve the dividend balance of any single address. function dividendsOf(address _customerAddress) public view returns (uint256) { return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /// @dev Return the sell price of 1 individual token. function sellPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /// @dev Return the buy price of 1 individual token. function buyPrice() public view returns (uint256) { // our calculation relies on the token supply, so we need supply. Doh. if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee_), 100); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /// @dev Function for the frontend to dynamically retrieve the price scaling of buy orders. function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /// @dev Function for the frontend to dynamically retrieve the price scaling of sell orders. function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseInternal(uint256 _incomingEthereum, address _referredBy) notContract()// no contracts allowed internal returns(uint256) { purchaseTokens(_incomingEthereum, _referredBy); } /// @dev Internal function to actually purchase the tokens. function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) { // data setup address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee_), 100); uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_); // is the user referred by a masternode? if ( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if (tokenSupply_ > 0) { // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / tokenSupply_); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee - (_amountOfTokens * (_dividends * magnitude / tokenSupply_))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; // really i know you think you do but you don't int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); return _amountOfTokens; } /** * @dev Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial ** 2) + (2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18)) + ((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2)) + (2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived; } /** * @dev Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2 ) / 1e18); return _etherReceived; } /// @dev This is where all your gas goes. function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
0x60606040526004361061011b5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166265318b811461012957806306fdde031461015a57806310d0ffdd146101e457806318160ddd146101fa578063226093731461020d578063313ce567146102235780633ccfd60b1461024c5780634000aea0146102615780634b750334146102a457806356d399e8146102b7578063688abbf7146102ca5780636b2f4632146102e257806370a08231146102f55780638620410b14610314578063949e8acd1461032757806395d89b411461033a578063a9059cbb1461034d578063e4849b321461036f578063e9fad8ee14610385578063f088d54714610398578063fdb5a03e146103ac575b6101263460006103bf565b50005b341561013457600080fd5b610148600160a060020a03600435166103f2565b60405190815260200160405180910390f35b341561016557600080fd5b61016d61042d565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101a9578082015183820152602001610191565b50505050905090810190601f1680156101d65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101ef57600080fd5b6101486004356104cb565b341561020557600080fd5b610148610505565b341561021857600080fd5b61014860043561050b565b341561022e57600080fd5b610236610547565b60405160ff909116815260200160405180910390f35b341561025757600080fd5b61025f61054c565b005b341561026c57600080fd5b61029060048035600160a060020a0316906024803591604435918201910135610618565b604051901515815260200160405180910390f35b34156102af57600080fd5b610148610719565b34156102c257600080fd5b610148610770565b34156102d557600080fd5b6101486004351515610776565b34156102ed57600080fd5b6101486107b9565b341561030057600080fd5b610148600160a060020a03600435166107c7565b341561031f57600080fd5b6101486107e2565b341561033257600080fd5b61014861082d565b341561034557600080fd5b61016d61083f565b341561035857600080fd5b610290600160a060020a03600435166024356108aa565b341561037a57600080fd5b61025f6004356109e2565b341561039057600080fd5b61025f610b64565b610148600160a060020a0360043516610b9b565b34156103b757600080fd5b61025f610ba7565b600032600160a060020a031633600160a060020a03161415156103e157600080fd5b6103eb8383610c62565b5092915050565b600160a060020a0316600090815260056020908152604080832054600390925290912054600754680100000000000000009102919091030490565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104c35780601f10610498576101008083540402835291602001916104c3565b820191906000526020600020905b8154815290600101906020018083116104a657829003601f168201915b505050505081565b60008080806104e56104de866005610ec3565b6064610ef5565b92506104f18584610f0c565b91506104fc82610f1e565b95945050505050565b60065490565b600080600080600654851115151561052257600080fd5b61052b85610fb0565b925061053b6104de846005610ec3565b91506104fc8383610f0c565b601281565b600080600061055b6001610776565b1161056557600080fd5b3391506105726000610776565b600160a060020a0383166000818152600560209081526040808320805468010000000000000000870201905560049091528082208054929055920192509082156108fc0290839051600060405180830381858888f1935050505015156105d757600080fd5b81600160a060020a03167fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc8260405190815260200160405180910390a25050565b600080600160a060020a038616151561063057600080fd5b61063a86866108aa565b151561064557600080fd5b61064e8661101a565b1561070d575084600160a060020a03811663c0ee0b8a338787876040517c010000000000000000000000000000000000000000000000000000000063ffffffff8716028152600160a060020a0385166004820190815260248201859052606060448301908152606483018490529091608401848480828437820191505095505050505050602060405180830381600087803b15156106eb57600080fd5b5af115156106f857600080fd5b50505060405180519050151561070d57600080fd5b50600195945050505050565b6000806000806006546000141561073757640218711a00935061076a565b610748670de0b6b3a7640000610fb0565b92506107586104de846005610ec3565b91506107648383610f0c565b90508093505b50505090565b60025481565b6000338261078c57610787816103f2565b6107b0565b600160a060020a0381166000908152600460205260409020546107ae826103f2565b015b91505b50919050565b600160a060020a0330163190565b600160a060020a031660009081526003602052604090205490565b600080600080600654600014156108005764028fa6ae00935061076a565b610811670de0b6b3a7640000610fb0565b92506108216104de846005610ec3565b91506107648383611022565b600033610839816107c7565b91505090565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104c35780601f10610498576101008083540402835291602001916104c3565b60008060006108b761082d565b116108c157600080fd5b5033600160a060020a0381166000908152600360205260409020548311156108e857600080fd5b60006108f46001610776565b11156109025761090261054c565b600160a060020a0381166000908152600360205260409020546109259084610f0c565b600160a060020a0380831660009081526003602052604080822093909355908616815220546109549084611022565b600160a060020a038581166000818152600360209081526040808320959095556007805494871680845260059092528583208054958a0290950390945592548282529084902080549188029091019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9086905190815260200160405180910390a35060019392505050565b60008060008060008060006109f561082d565b116109ff57600080fd5b33600160a060020a038116600090815260036020526040902054909650871115610a2857600080fd5b869450610a3485610fb0565b9350610a446104de856005610ec3565b9250610a508484610f0c565b9150610a5e60065486610f0c565b600655600160a060020a038616600090815260036020526040902054610a849086610f0c565b600160a060020a0387166000908152600360209081526040808320939093556007546005909152918120805492880268010000000000000000860201928390039055600654919250901115610afb57610af7600754600654680100000000000000008602811515610af157fe5b04611022565b6007555b85600160a060020a03167f8d3a0130073dbd54ab6ac632c05946df540553d3b514c9f8165b4ab7f2b1805e868442610b316107e2565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390a250505050505050565b33600160a060020a03811660009081526003602052604081205490811115610b8f57610b8f816109e2565b610b9761054c565b5050565b60006107b334836103bf565b600080600080610bb76001610776565b11610bc157600080fd5b610bcb6000610776565b33600160a060020a038116600090815260056020908152604080832080546801000000000000000087020190556004909152812080549082905590920194509250610c17908490610c62565b905081600160a060020a03167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab3615326458848360405191825260208201526040908101905180910390a2505050565b60003381808080808080610c7a6104de8c6005610ec3565b9650610c8a6104de88603c610ec3565b9550610c968787610f0c565b9450610ca28b88610f0c565b9350610cad84610f1e565b92506801000000000000000085029150600083118015610cd75750600654610cd58482611022565b115b1515610ce257600080fd5b600160a060020a038a1615801590610d0c575087600160a060020a03168a600160a060020a031614155b8015610d325750600254600160a060020a038b1660009081526003602052604090205410155b15610d7857600160a060020a038a16600090815260046020526040902054610d5a9087611022565b600160a060020a038b16600090815260046020526040902055610d93565b610d828587611022565b945068010000000000000000850291505b60006006541115610df757610daa60065484611022565b6006819055680100000000000000008602811515610dc457fe5b60078054929091049091019055600654680100000000000000008602811515610de957fe5b048302820382039150610dfd565b60068390555b600160a060020a038816600090815260036020526040902054610e209084611022565b600160a060020a03808a166000818152600360209081526040808320959095556007546005909152939020805493870286900393840190559192508b16907f8032875b28d82ddbd303a9e4e5529d047a14ecb6290f80012a81b7e6227ff1ab8d8642610e8a6107e2565b6040518085815260200184815260200183815260200182815260200194505050505060405180910390a350909998505050505050505050565b600080831515610ed657600091506103eb565b50828202828482811515610ee657fe5b0414610eee57fe5b9392505050565b6000808284811515610f0357fe5b04949350505050565b600082821115610f1857fe5b50900390565b6006546000906b204fce5e3e25026110000000908290633b9aca00610f9d610f977259aedfc10d7279c5eed140164540000000000088026002850a670de0b6b3a764000002016f0f0bdc21abb48db201e86d40000000008502017704140c78940f6a24fdffc78873d4490d210000000000000001611031565b85610f0c565b811515610fa657fe5b0403949350505050565b600654600090670de0b6b3a7640000838101918101908390611007640218711a00828504633b9aca0002018702600283670de0b6b3a763ffff1982890a8b90030104633b9aca000281151561100157fe5b04610f0c565b81151561101057fe5b0495945050505050565b6000903b1190565b600082820183811015610eee57fe5b80600260018201045b818110156107b357809150600281828581151561105357fe5b040181151561105e57fe5b04905061103a5600a165627a7a72305820b88717bbedaa600603be885f2851feeb0071fbb53933bd62317281f7c4183cfd0029
[ 1, 4 ]
0xf3cfbca4e083b1418f89545754c7da90d2418b10
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract GMBEL is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "G-Mbel"; string public constant symbol = "GMBEL"; uint public constant decimals = 18; uint256 public totalSupply = 7000000000000e18; uint256 public totalDistributed; uint256 public constant MIN_CONTRIBUTION = 1 ether / 10000; // 0.0001 Ether uint256 public tokensPerEth = 100000000e18; uint256 public initialBonus = 1000000e18; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event InitialBonusUpdated(uint _initialBonus); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function updateInitialBonus(uint _initialBonus) public onlyOwner { initialBonus = _initialBonus; emit InitialBonusUpdated(_initialBonus); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; require( msg.value >= MIN_CONTRIBUTION ); require( msg.value > 0 ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; bonus = tokens + initialBonus; if (Claimed[investor] == false) { distr(investor, bonus); Claimed[investor] = true; }else{ distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x60606040526004361061013a5763ffffffff60e060020a60003504166306fdde038114610144578063095ea7b3146101ce57806318160ddd1461020457806323b872dd14610229578063313ce567146102515780633ccfd60b1461026457806340650c911461027757806342966c681461028a57806370a08231146102a05780637809231c146102bf57806395d89b41146102e15780639b1cbccc146102f45780639ea407be14610307578063a9059cbb1461031d578063aa6ca8081461013a578063b449c24d1461033f578063c108d5421461035e578063c489744b14610371578063cbdd69b514610396578063dd62ed3e146103a9578063e58fc54c146103ce578063e7810318146103ed578063efca2eed14610403578063f2fde38b14610416578063f3ccb40114610435578063fb0d7e4314610457575b61014261046a565b005b341561014f57600080fd5b61015761055d565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561019357808201518382015260200161017b565b50505050905090810190601f1680156101c05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101d957600080fd5b6101f0600160a060020a0360043516602435610594565b604051901515815260200160405180910390f35b341561020f57600080fd5b610217610640565b60405190815260200160405180910390f35b341561023457600080fd5b6101f0600160a060020a0360043581169060243516604435610646565b341561025c57600080fd5b6102176107c4565b341561026f57600080fd5b6101426107c9565b341561028257600080fd5b610217610829565b341561029557600080fd5b610142600435610833565b34156102ab57600080fd5b610217600160a060020a0360043516610921565b34156102ca57600080fd5b610142600160a060020a036004351660243561093c565b34156102ec57600080fd5b610157610961565b34156102ff57600080fd5b6101f0610998565b341561031257600080fd5b610142600435610a05565b341561032857600080fd5b6101f0600160a060020a0360043516602435610a5b565b341561034a57600080fd5b6101f0600160a060020a0360043516610b52565b341561036957600080fd5b6101f0610b67565b341561037c57600080fd5b610217600160a060020a0360043581169060243516610b70565b34156103a157600080fd5b610217610be1565b34156103b457600080fd5b610217600160a060020a0360043581169060243516610be7565b34156103d957600080fd5b6101f0600160a060020a0360043516610c12565b34156103f857600080fd5b610142600435610d16565b341561040e57600080fd5b610217610d6c565b341561042157600080fd5b610142600160a060020a0360043516610d72565b341561044057600080fd5b610142602460048035828101929101359035610dc8565b341561046257600080fd5b610217610e25565b6009546000908190819060ff161561048157600080fd5b60009250829150655af3107a400034101561049b57600080fd5b600034116104a857600080fd5b600754670de0b6b3a7640000906104c5903463ffffffff610e2b16565b8115156104ce57fe5b60085433600160a060020a03811660009081526004602052604090205493909204955085019350915060ff1615156105335761050a8183610e54565b50600160a060020a0381166000908152600460205260409020805460ff1916600117905561053f565b61053d8184610e54565b505b60055460065410610558576009805460ff191660011790555b505050565b60408051908101604052600681527f472d4d62656c0000000000000000000000000000000000000000000000000000602082015281565b600081158015906105c95750600160a060020a0333811660009081526003602090815260408083209387168352929052205415155b156105d65750600061063a565b600160a060020a03338116600081815260036020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60055481565b60006060606436101561065557fe5b600160a060020a038416151561066a57600080fd5b600160a060020a03851660009081526002602052604090205483111561068f57600080fd5b600160a060020a03808616600090815260036020908152604080832033909416835292905220548311156106c257600080fd5b600160a060020a0385166000908152600260205260409020546106eb908463ffffffff610f2e16565b600160a060020a038087166000908152600260209081526040808320949094556003815283822033909316825291909152205461072e908463ffffffff610f2e16565b600160a060020a0380871660009081526003602090815260408083203385168452825280832094909455918716815260029091522054610774908463ffffffff610f4016565b600160a060020a038086166000818152600260205260409081902093909355919087169060008051602061107d8339815191529086905190815260200160405180910390a3506001949350505050565b601281565b600154600090819033600160a060020a039081169116146107e957600080fd5b50506001543090600160a060020a0380831631911681156108fc0282604051600060405180830381858888f19350505050151561082557600080fd5b5050565b655af3107a400081565b60015460009033600160a060020a0390811691161461085157600080fd5b600160a060020a03331660009081526002602052604090205482111561087657600080fd5b5033600160a060020a03811660009081526002602052604090205461089b9083610f2e565b600160a060020a0382166000908152600260205260409020556005546108c7908363ffffffff610f2e16565b6005556006546108dd908363ffffffff610f2e16565b600655600160a060020a0381167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58360405190815260200160405180910390a25050565b600160a060020a031660009081526002602052604090205490565b60015433600160a060020a0390811691161461095757600080fd5b6108258282610f4d565b60408051908101604052600581527f474d42454c000000000000000000000000000000000000000000000000000000602082015281565b60015460009033600160a060020a039081169116146109b657600080fd5b60095460ff16156109c657600080fd5b6009805460ff191660011790557f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a150600190565b60015433600160a060020a03908116911614610a2057600080fd5b60078190557ff7729fa834bbef70b6d3257c2317a562aa88b56c81b544814f93dc5963a2c0038160405190815260200160405180910390a150565b600060406044361015610a6a57fe5b600160a060020a0384161515610a7f57600080fd5b600160a060020a033316600090815260026020526040902054831115610aa457600080fd5b600160a060020a033316600090815260026020526040902054610acd908463ffffffff610f2e16565b600160a060020a033381166000908152600260205260408082209390935590861681522054610b02908463ffffffff610f4016565b600160a060020a03808616600081815260026020526040908190209390935591339091169060008051602061107d8339815191529086905190815260200160405180910390a35060019392505050565b60046020526000908152604090205460ff1681565b60095460ff1681565b60008281600160a060020a0382166370a082318560405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610bc257600080fd5b5af11515610bcf57600080fd5b50505060405180519695505050505050565b60075481565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b6001546000908190819033600160a060020a03908116911614610c3457600080fd5b83915081600160a060020a03166370a082313060405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b1515610c8557600080fd5b5af11515610c9257600080fd5b5050506040518051600154909250600160a060020a03808516925063a9059cbb91168360405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610cf857600080fd5b5af11515610d0557600080fd5b505050604051805195945050505050565b60015433600160a060020a03908116911614610d3157600080fd5b60088190557fc8c3020944c66bb9506eaeabbf32592e34d07a9e35dc19ce301e78144020619e8160405190815260200160405180910390a150565b60065481565b60015433600160a060020a03908116911614610d8d57600080fd5b600160a060020a03811615610dc5576001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b60015460009033600160a060020a03908116911614610de657600080fd5b5060005b82811015610e1f57610e17848483818110610e0157fe5b90506020020135600160a060020a031683610f4d565b600101610dea565b50505050565b60085481565b6000821515610e3c5750600061063a565b50818102818382811515610e4c57fe5b041461063a57fe5b60095460009060ff1615610e6757600080fd5b600654610e7a908363ffffffff610f4016565b600655600160a060020a038316600090815260026020526040902054610ea6908363ffffffff610f4016565b600160a060020a0384166000818152600260205260409081902092909255907f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a779084905190815260200160405180910390a2600160a060020a038316600060008051602061107d8339815191528460405190815260200160405180910390a350600192915050565b600082821115610f3a57fe5b50900390565b8181018281101561063a57fe5b60015433600160a060020a03908116911614610f6857600080fd5b60008111610f7557600080fd5b60055460065410610f8557600080fd5b600160a060020a038216600090815260026020526040902054610fae908263ffffffff610f4016565b600160a060020a038316600090815260026020526040902055600654610fda908263ffffffff610f4016565b60068190556005549010610ff6576009805460ff191660011790555b600160a060020a03821660008181526002602052604090819020547fada993ad066837289fe186cd37227aa338d27519a8a1547472ecb9831486d272918491905191825260208201526040908101905180910390a2600160a060020a038216600060008051602061107d8339815191528360405190815260200160405180910390a350505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058208425d020fd16d7c30bf3f82a7e47402b5cc80f2b32ca08b709df0d7c7c9a26c10029
[ 14 ]
0xf3cFfaEEa177Db444b68FB6f033d4a82f6D8C82d
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "hardhat/console.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../libraries/FixedPointMath.sol"; import {IDetailedERC20} from "../interfaces/IDetailedERC20.sol"; import {IVaultAdapter} from "../interfaces/IVaultAdapter.sol"; import {IyVaultV2} from "../interfaces/IyVaultV2.sol"; /// @title YearnVaultAdapter /// /// @dev A vault adapter implementation which wraps a yEarn vault. contract YearnVaultAdapter is IVaultAdapter { using FixedPointMath for FixedPointMath.FixedDecimal; using SafeERC20 for IDetailedERC20; using SafeMath for uint256; /// @dev The vault that the adapter is wrapping. IyVaultV2 public vault; /// @dev The address which has admin control over this contract. address public admin; /// @dev The decimals of the token. uint256 public decimals; constructor(IyVaultV2 _vault, address _admin) public { vault = _vault; admin = _admin; updateApproval(); decimals = _vault.decimals(); } /// @dev A modifier which reverts if the caller is not the admin. modifier onlyAdmin() { require(admin == msg.sender, "YearnVaultAdapter: only admin"); _; } /// @dev Gets the token that the vault accepts. /// /// @return the accepted token. function token() external view override returns (IDetailedERC20) { return IDetailedERC20(vault.token()); } /// @dev Gets the total value of the assets that the adapter holds in the vault. /// /// @return the total assets. function totalValue() external view override returns (uint256) { return _sharesToTokens(vault.balanceOf(address(this))); } /// @dev Deposits tokens into the vault. /// /// @param _amount the amount of tokens to deposit into the vault. function deposit(uint256 _amount) external override { vault.deposit(_amount); } /// @dev Withdraws tokens from the vault to the recipient. /// /// This function reverts if the caller is not the admin. /// /// @param _recipient the account to withdraw the tokes to. /// @param _amount the amount of tokens to withdraw. function withdraw(address _recipient, uint256 _amount) external override onlyAdmin { vault.withdraw(_tokensToShares(_amount),_recipient); } /// @dev Updates the vaults approval of the token to be the maximum value. function updateApproval() public { address _token = vault.token(); IDetailedERC20(_token).safeApprove(address(vault), uint256(-1)); } /// @dev Computes the number of tokens an amount of shares is worth. /// /// @param _sharesAmount the amount of shares. /// /// @return the number of tokens the shares are worth. function _sharesToTokens(uint256 _sharesAmount) internal view returns (uint256) { return _sharesAmount.mul(vault.pricePerShare()).div(10**decimals); } /// @dev Computes the number of shares an amount of tokens is worth. /// /// @param _tokensAmount the amount of shares. /// /// @return the number of shares the tokens are worth. function _tokensToShares(uint256 _tokensAmount) internal view returns (uint256) { return _tokensAmount.mul(10**decimals).div(vault.pricePerShare()); } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.8.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 logByte(byte p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(byte)", 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.6.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.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: Unlicense pragma solidity ^0.6.12; library FixedPointMath { uint256 public constant DECIMALS = 18; uint256 public constant SCALAR = 10**DECIMALS; struct FixedDecimal { uint256 x; } function fromU256(uint256 value) internal pure returns (FixedDecimal memory) { uint256 x; require(value == 0 || (x = value * SCALAR) / SCALAR == value); return FixedDecimal(x); } function maximumValue() internal pure returns (FixedDecimal memory) { return FixedDecimal(uint256(-1)); } function add(FixedDecimal memory self, FixedDecimal memory value) internal pure returns (FixedDecimal memory) { uint256 x; require((x = self.x + value.x) >= self.x); return FixedDecimal(x); } function add(FixedDecimal memory self, uint256 value) internal pure returns (FixedDecimal memory) { return add(self, fromU256(value)); } function sub(FixedDecimal memory self, FixedDecimal memory value) internal pure returns (FixedDecimal memory) { uint256 x; require((x = self.x - value.x) <= self.x); return FixedDecimal(x); } function sub(FixedDecimal memory self, uint256 value) internal pure returns (FixedDecimal memory) { return sub(self, fromU256(value)); } function mul(FixedDecimal memory self, uint256 value) internal pure returns (FixedDecimal memory) { uint256 x; require(value == 0 || (x = self.x * value) / value == self.x); return FixedDecimal(x); } function div(FixedDecimal memory self, uint256 value) internal pure returns (FixedDecimal memory) { require(value != 0); return FixedDecimal(self.x / value); } function cmp(FixedDecimal memory self, FixedDecimal memory value) internal pure returns (int256) { if (self.x < value.x) { return -1; } if (self.x > value.x) { return 1; } return 0; } function decode(FixedDecimal memory self) internal pure returns (uint256) { return self.x / SCALAR; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IDetailedERC20 is IERC20 { function name() external returns (string memory); function symbol() external returns (string memory); function decimals() external returns (uint8); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./IDetailedERC20.sol"; /// Interface for all Vault Adapter implementations. interface IVaultAdapter { /// @dev Gets the token that the adapter accepts. function token() external view returns (IDetailedERC20); /// @dev The total value of the assets deposited into the vault. function totalValue() external view returns (uint256); /// @dev Deposits funds into the vault. /// /// @param _amount the amount of funds to deposit. function deposit(uint256 _amount) external; /// @dev Attempts to withdraw funds from the wrapped vault. /// /// The amount withdrawn to the recipient may be less than the amount requested. /// /// @param _recipient the recipient of the funds. /// @param _amount the amount of funds to withdraw. function withdraw(address _recipient, uint256 _amount) external; } pragma solidity ^0.6.12; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IyVaultV2 is IERC20 { function token() external view returns (address); function deposit() external returns (uint); function deposit(uint) external returns (uint); function deposit(uint, address) external returns (uint); function withdraw() external returns (uint); function withdraw(uint) external returns (uint); function withdraw(uint, address) external returns (uint); function withdraw(uint, address, uint) external returns (uint); function permit(address, address, uint, uint, bytes32) external view returns (bool); function pricePerShare() external view returns (uint); function apiVersion() external view returns (string memory); function totalAssets() external view returns (uint); function maxAvailableShares() external view returns (uint); function debtOutstanding() external view returns (uint); function debtOutstanding(address strategy) external view returns (uint); function creditAvailable() external view returns (uint); function creditAvailable(address strategy) external view returns (uint); function availableDepositLimit() external view returns (uint); function expectedReturn() external view returns (uint); function expectedReturn(address strategy) external view returns (uint); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint); function balanceOf(address owner) external view override returns (uint); function totalSupply() external view override returns (uint); function governance() external view returns (address); function management() external view returns (address); function guardian() external view returns (address); function guestList() external view returns (address); function strategies(address) external view returns (uint, uint, uint, uint, uint, uint, uint, uint); function withdrawalQueue(uint) external view returns (address); function emergencyShutdown() external view returns (bool); function depositLimit() external view returns (uint); function debtRatio() external view returns (uint); function totalDebt() external view returns (uint); function lastReport() external view returns (uint); function activation() external view returns (uint); function rewards() external view returns (address); function managementFee() external view returns (uint); function performanceFee() external view returns (uint); } // 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) { // 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); } } } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "hardhat/console.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../libraries/FixedPointMath.sol"; import {IDetailedERC20} from "../interfaces/IDetailedERC20.sol"; import {IVaultAdapter} from "../interfaces/IVaultAdapter.sol"; import {IyVaultV2} from "../interfaces/IyVaultV2.sol"; import {YearnVaultAdapter} from "./YearnVaultAdapter.sol"; /// @title YearnVaultAdapter /// /// @dev A vault adapter implementation which wraps a yEarn vault. contract YearnVaultAdapterWithIndirection is YearnVaultAdapter { using FixedPointMath for FixedPointMath.FixedDecimal; using SafeERC20 for IDetailedERC20; using SafeERC20 for IyVaultV2; using SafeMath for uint256; constructor(IyVaultV2 _vault, address _admin) YearnVaultAdapter(_vault, _admin) public { } /// @dev Sends vault tokens to the recipient /// /// This function reverts if the caller is not the admin. /// /// @param _recipient the account to send the tokens to. /// @param _amount the amount of tokens to send. function indirectWithdraw(address _recipient, uint256 _amount) external onlyAdmin { vault.safeTransfer(_recipient, _tokensToShares(_amount)); } } pragma solidity 0.6.12; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./interfaces/IERC20Burnable.sol"; import {YearnVaultAdapterWithIndirection} from "./adapters/YearnVaultAdapterWithIndirection.sol"; import {VaultWithIndirection} from "./libraries/alchemist/VaultWithIndirection.sol"; import {ITransmuter} from "./interfaces/ITransmuter.sol"; // import "hardhat/console.sol"; // ___ __ __ _ ___ __ _ // / _ | / / ____ / / ___ __ _ (_) __ __ / _ \ ____ ___ ___ ___ ___ / /_ ___ (_) // / __ | / / / __/ / _ \/ -_) / ' \ / / \ \ / / ___/ / __// -_) (_-</ -_) / _ \/ __/ (_-< _ // /_/ |_|/_/ \__/ /_//_/\__/ /_/_/_//_/ /_\_\ /_/ /_/ \__/ /___/\__/ /_//_/\__/ /___/(_) // // .___________..______ ___ .__ __. _______..___ ___. __ __ .___________. _______ .______ // | || _ \ / \ | \ | | / || \/ | | | | | | || ____|| _ \ // `---| |----`| |_) | / ^ \ | \| | | (----`| \ / | | | | | `---| |----`| |__ | |_) | // | | | / / /_\ \ | . ` | \ \ | |\/| | | | | | | | | __| | / // | | | |\ \----. / _____ \ | |\ | .----) | | | | | | `--' | | | | |____ | |\ \----. // |__| | _| `._____|/__/ \__\ |__| \__| |_______/ |__| |__| \______/ |__| |_______|| _| `._____| /** * @dev Implementation of the {IERC20Burnable} 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 {IERC20Burnable-approve}. */ contract TransmuterB is Context { using SafeMath for uint256; using SafeERC20 for IERC20Burnable; using Address for address; using VaultWithIndirection for VaultWithIndirection.Data; using VaultWithIndirection for VaultWithIndirection.List; address public constant ZERO_ADDRESS = address(0); uint256 public TRANSMUTATION_PERIOD; address public alToken; address public token; mapping(address => uint256) public depositedAlTokens; mapping(address => uint256) public tokensInBucket; mapping(address => uint256) public realisedTokens; mapping(address => uint256) public lastDividendPoints; mapping(address => bool) public userIsKnown; mapping(uint256 => address) public userList; uint256 public nextUser; uint256 public totalSupplyAltokens; uint256 public buffer; uint256 public lastDepositBlock; ///@dev values needed to calculate the distribution of base asset in proportion for alTokens staked uint256 public pointMultiplier = 10e18; uint256 public totalDividendPoints; uint256 public unclaimedDividends; /// @dev alchemist addresses whitelisted mapping (address => bool) public whiteList; /// @dev The threshold above which excess funds will be deployed to yield farming activities uint256 public plantableThreshold = 5000000000000000000000000; // 5mm /// @dev The % margin to trigger planting or recalling of funds uint256 public plantableMargin = 5; /// @dev The address of the account which currently has administrative capabilities over this contract. address public governance; /// @dev The address of the pending governance. address public pendingGovernance; /// @dev The address of the account which can perform emergency activities address public sentinel; /// @dev A flag indicating if deposits and flushes should be halted and if all parties should be able to recall /// from the active vault. bool public pause; /// @dev The address of the contract which will receive fees. address public rewards; /// @dev A list of all of the vaults. The last element of the list is the vault that is currently being used for /// deposits and withdraws. VaultWithIndirections before the last element are considered inactive and are expected to be cleared. VaultWithIndirection.List private _vaults; event GovernanceUpdated( address governance ); event PendingGovernanceUpdated( address pendingGovernance ); event SentinelUpdated( address sentinel ); event TransmuterPeriodUpdated( uint256 newTransmutationPeriod ); event TokenClaimed( address claimant, address token, uint256 amountClaimed ); event AlUsdStaked( address staker, uint256 amountStaked ); event AlUsdUnstaked( address staker, uint256 amountUnstaked ); event Transmutation( address transmutedTo, uint256 amountTransmuted ); event ForcedTransmutation( address transmutedBy, address transmutedTo, uint256 amountTransmuted ); event Distribution( address origin, uint256 amount ); event WhitelistSet( address whitelisted, bool state ); event PlantableThresholdUpdated( uint256 plantableThreshold ); event PlantableMarginUpdated( uint256 plantableMargin ); event ActiveVaultUpdated( YearnVaultAdapterWithIndirection indexed adapter ); event PauseUpdated( bool status ); event FundsRecalled( uint256 indexed vaultId, uint256 withdrawnAmount, uint256 decreasedValue ); event FundsHarvested( uint256 withdrawnAmount, uint256 decreasedValue ); event RewardsUpdated( address treasury ); event MigrationComplete( address migrateTo, uint256 fundsMigrated ); constructor(address _alToken, address _token, address _governance) public { require(_governance != ZERO_ADDRESS, "Transmuter: 0 gov"); governance = _governance; alToken = _alToken; token = _token; TRANSMUTATION_PERIOD = 50; } ///@return displays the user's share of the pooled alTokens. function dividendsOwing(address account) public view returns (uint256) { uint256 newDividendPoints = totalDividendPoints.sub(lastDividendPoints[account]); return depositedAlTokens[account].mul(newDividendPoints).div(pointMultiplier); } ///@dev modifier to fill the bucket and keep bookkeeping correct incase of increase/decrease in shares modifier updateAccount(address account) { uint256 owing = dividendsOwing(account); if (owing > 0) { unclaimedDividends = unclaimedDividends.sub(owing); tokensInBucket[account] = tokensInBucket[account].add(owing); } lastDividendPoints[account] = totalDividendPoints; _; } ///@dev modifier add users to userlist. Users are indexed in order to keep track of when a bond has been filled modifier checkIfNewUser() { if (!userIsKnown[msg.sender]) { userList[nextUser] = msg.sender; userIsKnown[msg.sender] = true; nextUser++; } _; } ///@dev run the phased distribution of the buffered funds modifier runPhasedDistribution() { uint256 _lastDepositBlock = lastDepositBlock; uint256 _currentBlock = block.number; uint256 _toDistribute = 0; uint256 _buffer = buffer; // check if there is something in bufffer if (_buffer > 0) { // NOTE: if last deposit was updated in the same block as the current call // then the below logic gates will fail //calculate diffrence in time uint256 deltaTime = _currentBlock.sub(_lastDepositBlock); // distribute all if bigger than timeframe if(deltaTime >= TRANSMUTATION_PERIOD) { _toDistribute = _buffer; } else { //needs to be bigger than 0 cuzz solidity no decimals if(_buffer.mul(deltaTime) > TRANSMUTATION_PERIOD) { _toDistribute = _buffer.mul(deltaTime).div(TRANSMUTATION_PERIOD); } } // factually allocate if any needs distribution if(_toDistribute > 0){ // remove from buffer buffer = _buffer.sub(_toDistribute); // increase the allocation increaseAllocations(_toDistribute); } } // current timeframe is now the last lastDepositBlock = _currentBlock; _; } /// @dev A modifier which checks if whitelisted for minting. modifier onlyWhitelisted() { require(whiteList[msg.sender], "Transmuter: !whitelisted"); _; } /// @dev Checks that the current message sender or caller is the governance address. /// /// modifier onlyGov() { require(msg.sender == governance, "Transmuter: !governance"); _; } ///@dev set the TRANSMUTATION_PERIOD variable /// /// sets the length (in blocks) of one full distribution phase function setTransmutationPeriod(uint256 newTransmutationPeriod) public onlyGov() { TRANSMUTATION_PERIOD = newTransmutationPeriod; emit TransmuterPeriodUpdated(TRANSMUTATION_PERIOD); } ///@dev claims the base token after it has been transmuted /// ///This function reverts if there is no realisedToken balance function claim() public { address sender = msg.sender; require(realisedTokens[sender] > 0); uint256 value = realisedTokens[sender]; realisedTokens[sender] = 0; ensureSufficientFundsExistLocally(value); IERC20Burnable(token).safeTransfer(sender, value); emit TokenClaimed(sender, token, value); } ///@dev Withdraws staked alTokens from the transmuter /// /// This function reverts if you try to draw more tokens than you deposited /// ///@param amount the amount of alTokens to unstake function unstake(uint256 amount) public updateAccount(msg.sender) { // by calling this function before transmuting you forfeit your gained allocation address sender = msg.sender; require(depositedAlTokens[sender] >= amount,"Transmuter: unstake amount exceeds deposited amount"); depositedAlTokens[sender] = depositedAlTokens[sender].sub(amount); totalSupplyAltokens = totalSupplyAltokens.sub(amount); IERC20Burnable(alToken).safeTransfer(sender, amount); emit AlUsdUnstaked(sender, amount); } ///@dev Deposits alTokens into the transmuter /// ///@param amount the amount of alTokens to stake function stake(uint256 amount) public runPhasedDistribution() updateAccount(msg.sender) checkIfNewUser() { require(!pause, "emergency pause enabled"); // requires approval of AlToken first address sender = msg.sender; //require tokens transferred in; IERC20Burnable(alToken).safeTransferFrom(sender, address(this), amount); totalSupplyAltokens = totalSupplyAltokens.add(amount); depositedAlTokens[sender] = depositedAlTokens[sender].add(amount); emit AlUsdStaked(sender, amount); } /// @dev Converts the staked alTokens to the base tokens in amount of the sum of pendingdivs and tokensInBucket /// /// once the alToken has been converted, it is burned, and the base token becomes realisedTokens which can be recieved using claim() /// /// reverts if there are no pendingdivs or tokensInBucket function transmute() public runPhasedDistribution() updateAccount(msg.sender) { address sender = msg.sender; uint256 pendingz = tokensInBucket[sender]; uint256 diff; require(pendingz > 0, "need to have pending in bucket"); tokensInBucket[sender] = 0; // check bucket overflow if (pendingz > depositedAlTokens[sender]) { diff = pendingz.sub(depositedAlTokens[sender]); // remove overflow pendingz = depositedAlTokens[sender]; } // decrease altokens depositedAlTokens[sender] = depositedAlTokens[sender].sub(pendingz); // BURN ALTOKENS IERC20Burnable(alToken).burn(pendingz); // adjust total totalSupplyAltokens = totalSupplyAltokens.sub(pendingz); // reallocate overflow increaseAllocations(diff); // add payout realisedTokens[sender] = realisedTokens[sender].add(pendingz); emit Transmutation(sender, pendingz); } /// @dev Executes transmute() on another account that has had more base tokens allocated to it than alTokens staked. /// /// The caller of this function will have the surlus base tokens credited to their tokensInBucket balance, rewarding them for performing this action /// /// This function reverts if the address to transmute is not over-filled. /// /// @param toTransmute address of the account you will force transmute. function forceTransmute(address toTransmute) public runPhasedDistribution() updateAccount(msg.sender) updateAccount(toTransmute) checkIfNewUser() { //load into memory address sender = msg.sender; uint256 pendingz = tokensInBucket[toTransmute]; // check restrictions require( pendingz > depositedAlTokens[toTransmute], "Transmuter: !overflow" ); // empty bucket tokensInBucket[toTransmute] = 0; // calculaate diffrence uint256 diff = pendingz.sub(depositedAlTokens[toTransmute]); // remove overflow pendingz = depositedAlTokens[toTransmute]; // decrease altokens depositedAlTokens[toTransmute] = 0; // BURN ALTOKENS IERC20Burnable(alToken).burn(pendingz); // adjust total totalSupplyAltokens = totalSupplyAltokens.sub(pendingz); // reallocate overflow tokensInBucket[sender] = tokensInBucket[sender].add(diff); // add payout realisedTokens[toTransmute] = realisedTokens[toTransmute].add(pendingz); uint256 value = realisedTokens[toTransmute]; ensureSufficientFundsExistLocally(value); // force payout of realised tokens of the toTransmute address realisedTokens[toTransmute] = 0; IERC20Burnable(token).safeTransfer(toTransmute, value); emit ForcedTransmutation(sender, toTransmute, value); } /// @dev Transmutes and unstakes all alTokens /// /// This function combines the transmute and unstake functions for ease of use function exit() public { transmute(); uint256 toWithdraw = depositedAlTokens[msg.sender]; unstake(toWithdraw); } /// @dev Transmutes and claims all converted base tokens. /// /// This function combines the transmute and claim functions while leaving your remaining alTokens staked. function transmuteAndClaim() public { transmute(); claim(); } /// @dev Transmutes, claims base tokens, and withdraws alTokens. /// /// This function helps users to exit the transmuter contract completely after converting their alTokens to the base pair. function transmuteClaimAndWithdraw() public { transmute(); claim(); uint256 toWithdraw = depositedAlTokens[msg.sender]; unstake(toWithdraw); } /// @dev Distributes the base token proportionally to all alToken stakers. /// /// This function is meant to be called by the Alchemist contract for when it is sending yield to the transmuter. /// Anyone can call this and add funds, idk why they would do that though... /// /// @param origin the account that is sending the tokens to be distributed. /// @param amount the amount of base tokens to be distributed to the transmuter. function distribute(address origin, uint256 amount) public onlyWhitelisted() runPhasedDistribution() { require(!pause, "emergency pause enabled"); IERC20Burnable(token).safeTransferFrom(origin, address(this), amount); buffer = buffer.add(amount); _plantOrRecallExcessFunds(); emit Distribution(origin, amount); } /// @dev Allocates the incoming yield proportionally to all alToken stakers. /// /// @param amount the amount of base tokens to be distributed in the transmuter. function increaseAllocations(uint256 amount) internal { if(totalSupplyAltokens > 0 && amount > 0) { totalDividendPoints = totalDividendPoints.add( amount.mul(pointMultiplier).div(totalSupplyAltokens) ); unclaimedDividends = unclaimedDividends.add(amount); } else { buffer = buffer.add(amount); } } /// @dev Gets the status of a user's staking position. /// /// The total amount allocated to a user is the sum of pendingdivs and inbucket. /// /// @param user the address of the user you wish to query. /// /// returns user status function userInfo(address user) public view returns ( uint256 depositedAl, uint256 pendingdivs, uint256 inbucket, uint256 realised ) { uint256 _depositedAl = depositedAlTokens[user]; uint256 _toDistribute = buffer.mul(block.number.sub(lastDepositBlock)).div(TRANSMUTATION_PERIOD); if(block.number.sub(lastDepositBlock) > TRANSMUTATION_PERIOD){ _toDistribute = buffer; } uint256 _pendingdivs = _toDistribute.mul(depositedAlTokens[user]).div(totalSupplyAltokens); uint256 _inbucket = tokensInBucket[user].add(dividendsOwing(user)); uint256 _realised = realisedTokens[user]; return (_depositedAl, _pendingdivs, _inbucket, _realised); } /// @dev Gets the status of multiple users in one call /// /// This function is used to query the contract to check for /// accounts that have overfilled positions in order to check /// who can be force transmuted. /// /// @param from the first index of the userList /// @param to the last index of the userList /// /// returns the userList with their staking status in paginated form. function getMultipleUserInfo(uint256 from, uint256 to) public view returns (address[] memory theUserList, uint256[] memory theUserData) { uint256 i = from; uint256 delta = to - from; address[] memory _theUserList = new address[](delta); //user uint256[] memory _theUserData = new uint256[](delta * 2); //deposited-bucket uint256 y = 0; uint256 _toDistribute = buffer.mul(block.number.sub(lastDepositBlock)).div(TRANSMUTATION_PERIOD); if(block.number.sub(lastDepositBlock) > TRANSMUTATION_PERIOD){ _toDistribute = buffer; } for (uint256 x = 0; x < delta; x += 1) { _theUserList[x] = userList[i]; _theUserData[y] = depositedAlTokens[userList[i]]; _theUserData[y + 1] = dividendsOwing(userList[i]).add(tokensInBucket[userList[i]]).add(_toDistribute.mul(depositedAlTokens[userList[i]]).div(totalSupplyAltokens)); y += 2; i += 1; } return (_theUserList, _theUserData); } /// @dev Gets info on the buffer /// /// This function is used to query the contract to get the /// latest state of the buffer /// /// @return _toDistribute the amount ready to be distributed /// @return _deltaBlocks the amount of time since the last phased distribution /// @return _buffer the amount in the buffer function bufferInfo() public view returns (uint256 _toDistribute, uint256 _deltaBlocks, uint256 _buffer){ _deltaBlocks = block.number.sub(lastDepositBlock); _buffer = buffer; _toDistribute = _buffer.mul(_deltaBlocks).div(TRANSMUTATION_PERIOD); } /// @dev Sets the pending governance. /// /// This function reverts if the new pending governance is the zero address or the caller is not the current /// governance. This is to prevent the contract governance being set to the zero address which would deadlock /// privileged contract functionality. /// /// @param _pendingGovernance the new pending governance. function setPendingGovernance(address _pendingGovernance) external onlyGov() { require(_pendingGovernance != ZERO_ADDRESS, "Transmuter: 0 gov"); pendingGovernance = _pendingGovernance; emit PendingGovernanceUpdated(_pendingGovernance); } /// @dev Accepts the role as governance. /// /// This function reverts if the caller is not the new pending governance. function acceptGovernance() external { require(msg.sender == pendingGovernance,"!pendingGovernance"); address _pendingGovernance = pendingGovernance; governance = _pendingGovernance; emit GovernanceUpdated(_pendingGovernance); } /// @dev Sets the whitelist /// /// This function reverts if the caller is not governance /// /// @param _toWhitelist the account to mint tokens to. /// @param _state the whitelist state. function setWhitelist(address _toWhitelist, bool _state) external onlyGov() { whiteList[_toWhitelist] = _state; emit WhitelistSet(_toWhitelist, _state); } /// @dev Updates the active vault. /// /// This function reverts if the vault adapter is the zero address, if the token that the vault adapter accepts /// is not the token that this contract defines as the parent asset, or if the contract has not yet been initialized. /// /// @param _adapter the adapter for the new active vault. function setActiveVault(YearnVaultAdapterWithIndirection _adapter) external onlyGov() { require(_adapter != YearnVaultAdapterWithIndirection(ZERO_ADDRESS), "Transmuter: active vault address cannot be 0x0."); require(address(_adapter.token()) == token, "Transmuter.vault: token mismatch."); _vaults.push(VaultWithIndirection.Data({ adapter: _adapter, totalDeposited: 0 })); emit ActiveVaultUpdated(_adapter); } /// @dev Recalls funds from active vault if less than amt exist locally /// /// @param amt amount of funds that need to exist locally to fulfill pending request function ensureSufficientFundsExistLocally(uint256 amt) internal { uint256 currentBal = IERC20Burnable(token).balanceOf(address(this)); if (currentBal < amt) { uint256 diff = amt - currentBal; // get enough funds from active vault to replenish local holdings & fulfill claim request _recallExcessFundsFromActiveVault(plantableThreshold.add(diff)); } } /// @dev Recalls all planted funds from a target vault /// /// @param _vaultId the id of the vault from which to recall funds function recallAllFundsFromVault(uint256 _vaultId) external { require(pause && (msg.sender == governance || msg.sender == sentinel), "Transmuter: not paused, or not governance or sentinel"); _recallAllFundsFromVault(_vaultId); } /// @dev Recalls all planted funds from a target vault /// /// @param _vaultId the id of the vault from which to recall funds function _recallAllFundsFromVault(uint256 _vaultId) internal { VaultWithIndirection.Data storage _vault = _vaults.get(_vaultId); (uint256 _withdrawnAmount, uint256 _decreasedValue) = _vault.withdrawAll(address(this)); emit FundsRecalled(_vaultId, _withdrawnAmount, _decreasedValue); } /// @dev Recalls planted funds from a target vault /// /// @param _vaultId the id of the vault from which to recall funds /// @param _amount the amount of funds to recall function recallFundsFromVault(uint256 _vaultId, uint256 _amount) external { require(pause && (msg.sender == governance || msg.sender == sentinel), "Transmuter: not paused, or not governance or sentinel"); _recallFundsFromVault(_vaultId, _amount); } /// @dev Recalls planted funds from a target vault /// /// @param _vaultId the id of the vault from which to recall funds /// @param _amount the amount of funds to recall function _recallFundsFromVault(uint256 _vaultId, uint256 _amount) internal { VaultWithIndirection.Data storage _vault = _vaults.get(_vaultId); (uint256 _withdrawnAmount, uint256 _decreasedValue) = _vault.withdraw(address(this), _amount); emit FundsRecalled(_vaultId, _withdrawnAmount, _decreasedValue); } /// @dev Recalls planted funds from the active vault /// /// @param _amount the amount of funds to recall function _recallFundsFromActiveVault(uint256 _amount) internal { _recallFundsFromVault(_vaults.lastIndex(), _amount); } /// @dev Plants or recalls funds from the active vault /// /// This function plants excess funds in an external vault, or recalls them from the external vault /// Should only be called as part of distribute() function _plantOrRecallExcessFunds() internal { // check if the transmuter holds more funds than plantableThreshold uint256 bal = IERC20Burnable(token).balanceOf(address(this)); uint256 marginVal = plantableThreshold.mul(plantableMargin).div(100); if (bal > plantableThreshold.add(marginVal)) { uint256 plantAmt = bal - plantableThreshold; // if total funds above threshold, send funds to vault VaultWithIndirection.Data storage _activeVault = _vaults.last(); _activeVault.deposit(plantAmt); } else if (bal < plantableThreshold.sub(marginVal)) { // if total funds below threshold, recall funds from vault // first check that there are enough funds in vault uint256 harvestAmt = plantableThreshold - bal; _recallExcessFundsFromActiveVault(harvestAmt); } } /// @dev Recalls up to the harvestAmt from the active vault /// /// This function will recall less than harvestAmt if only less is available /// /// @param _recallAmt the amount to harvest from the active vault function _recallExcessFundsFromActiveVault(uint256 _recallAmt) internal { VaultWithIndirection.Data storage _activeVault = _vaults.last(); uint256 activeVaultVal = _activeVault.totalValue(); if (activeVaultVal < _recallAmt) { _recallAmt = activeVaultVal; } if (_recallAmt > 0) { _recallFundsFromActiveVault(_recallAmt); } } /// @dev Sets the address of the sentinel /// /// @param _sentinel address of the new sentinel function setSentinel(address _sentinel) external onlyGov() { require(_sentinel != ZERO_ADDRESS, "Transmuter: sentinel address cannot be 0x0."); sentinel = _sentinel; emit SentinelUpdated(_sentinel); } /// @dev Sets the threshold of total held funds above which excess funds will be planted in yield farms. /// /// This function reverts if the caller is not the current governance. /// /// @param _plantableThreshold the new plantable threshold. function setPlantableThreshold(uint256 _plantableThreshold) external onlyGov() { plantableThreshold = _plantableThreshold; emit PlantableThresholdUpdated(_plantableThreshold); } /// @dev Sets the plantableThreshold margin for triggering the planting or recalling of funds on harvest /// /// This function reverts if the caller is not the current governance. /// /// @param _plantableMargin the new plantable margin. function setPlantableMargin(uint256 _plantableMargin) external onlyGov() { plantableMargin = _plantableMargin; emit PlantableMarginUpdated(_plantableMargin); } /// @dev Sets if the contract should enter emergency exit mode. /// /// There are 2 main reasons to pause: /// 1. Need to shut down deposits in case of an emergency in one of the vaults /// 2. Need to migrate to a new transmuter /// /// While the transmuter is paused, deposit() and distribute() are disabled /// /// @param _pause if the contract should enter emergency exit mode. function setPause(bool _pause) external { require(msg.sender == governance || msg.sender == sentinel, "!(gov || sentinel)"); pause = _pause; emit PauseUpdated(_pause); } /// @dev Harvests yield from a vault. /// /// @param _vaultId the identifier of the vault to harvest from. /// /// @return the amount of funds that were harvested from the vault. function harvest(uint256 _vaultId) external returns (uint256, uint256) { VaultWithIndirection.Data storage _vault = _vaults.get(_vaultId); (uint256 _harvestedAmount, uint256 _decreasedValue) = _vault.harvest(rewards); emit FundsHarvested(_harvestedAmount, _decreasedValue); return (_harvestedAmount, _decreasedValue); } /// @dev Sets the rewards contract. /// /// This function reverts if the new rewards contract is the zero address or the caller is not the current governance. /// /// @param _rewards the new rewards contract. function setRewards(address _rewards) external onlyGov() { // Check that the rewards address is not the zero address. Setting the rewards to the zero address would break // transfers to the address because of `safeTransfer` checks. require(_rewards != ZERO_ADDRESS, "Transmuter: rewards address cannot be 0x0."); rewards = _rewards; emit RewardsUpdated(_rewards); } /// @dev Migrates transmuter funds to a new transmuter /// /// @param migrateTo address of the new transmuter function migrateFunds(address migrateTo) external onlyGov() { require(migrateTo != address(0), "cannot migrate to 0x0"); require(pause, "migrate: set emergency exit first"); // leave enough funds to service any pending transmutations uint256 totalFunds = IERC20Burnable(token).balanceOf(address(this)); uint256 migratableFunds = totalFunds.sub(totalSupplyAltokens, "not enough funds to service stakes"); IERC20Burnable(token).approve(migrateTo, migratableFunds); ITransmuter(migrateTo).distribute(address(this), migratableFunds); emit MigrationComplete(migrateTo, migratableFunds); } } // 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: GPL-3.0 pragma solidity ^0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20Burnable is IERC20 { function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; //import "hardhat/console.sol"; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; import {YearnVaultAdapterWithIndirection} from "../../adapters/YearnVaultAdapterWithIndirection.sol"; import "hardhat/console.sol"; /// @title Pool /// /// @dev A library which provides the Vault data struct and associated functions. library VaultWithIndirection { using VaultWithIndirection for Data; using VaultWithIndirection for List; using SafeERC20 for IDetailedERC20; using SafeMath for uint256; struct Data { YearnVaultAdapterWithIndirection adapter; uint256 totalDeposited; } struct List { Data[] elements; } /// @dev Gets the total amount of assets deposited in the vault. /// /// @return the total assets. function totalValue(Data storage _self) internal view returns (uint256) { return _self.adapter.totalValue(); } /// @dev Gets the token that the vault accepts. /// /// @return the accepted token. function token(Data storage _self) internal view returns (IDetailedERC20) { return IDetailedERC20(_self.adapter.token()); } /// @dev Deposits funds from the caller into the vault. /// /// @param _amount the amount of funds to deposit. function deposit(Data storage _self, uint256 _amount) internal returns (uint256) { // Push the token that the vault accepts onto the stack to save gas. IDetailedERC20 _token = _self.token(); _token.safeTransfer(address(_self.adapter), _amount); _self.adapter.deposit(_amount); _self.totalDeposited = _self.totalDeposited.add(_amount); return _amount; } /// @dev Deposits the entire token balance of the caller into the vault. function depositAll(Data storage _self) internal returns (uint256) { IDetailedERC20 _token = _self.token(); return _self.deposit(_token.balanceOf(address(this))); } /// @dev Withdraw deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. /// @param _amount the amount of tokens to withdraw. function withdraw(Data storage _self, address _recipient, uint256 _amount) internal returns (uint256, uint256) { (uint256 _withdrawnAmount, uint256 _decreasedValue) = _self.directWithdraw(_recipient, _amount); _self.totalDeposited = _self.totalDeposited.sub(_decreasedValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Directly withdraw deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. /// @param _amount the amount of tokens to withdraw. function directWithdraw(Data storage _self, address _recipient, uint256 _amount) internal returns (uint256, uint256) { IDetailedERC20 _token = _self.token(); uint256 _startingBalance = _token.balanceOf(_recipient); uint256 _startingTotalValue = _self.totalValue(); _self.adapter.withdraw(_recipient, _amount); uint256 _endingBalance = _token.balanceOf(_recipient); uint256 _withdrawnAmount = _endingBalance.sub(_startingBalance); uint256 _endingTotalValue = _self.totalValue(); uint256 _decreasedValue = _startingTotalValue.sub(_endingTotalValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Directly withdraw deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. /// @param _amount the amount of tokens to withdraw. function indirectWithdraw(Data storage _self, address _recipient, uint256 _amount) internal returns (uint256, uint256) { IDetailedERC20 _token = _self.token(); uint256 _startingBalance = _token.balanceOf(_recipient); uint256 _startingTotalValue = _self.totalValue(); _self.adapter.indirectWithdraw(_recipient, _amount); uint256 _endingBalance = _token.balanceOf(_recipient); uint256 _withdrawnAmount = _endingBalance.sub(_startingBalance); uint256 _endingTotalValue = _self.totalValue(); uint256 _decreasedValue = _startingTotalValue.sub(_endingTotalValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Withdraw all the deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. function withdrawAll(Data storage _self, address _recipient) internal returns (uint256, uint256) { return _self.withdraw(_recipient, _self.totalDeposited); } /// @dev Harvests yield from the vault. /// /// @param _recipient the account to withdraw the harvested yield to. function harvest(Data storage _self, address _recipient) internal returns (uint256, uint256) { if (_self.totalValue() <= _self.totalDeposited) { return (0, 0); } uint256 _withdrawAmount = _self.totalValue().sub(_self.totalDeposited); return _self.indirectWithdraw(_recipient, _withdrawAmount); } /// @dev Adds a element to the list. /// /// @param _element the element to add. function push(List storage _self, Data memory _element) internal { _self.elements.push(_element); } /// @dev Gets a element from the list. /// /// @param _index the index in the list. /// /// @return the element at the specified index. function get(List storage _self, uint256 _index) internal view returns (Data storage) { return _self.elements[_index]; } /// @dev Gets the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the last element in the list. function last(List storage _self) internal view returns (Data storage) { return _self.elements[_self.lastIndex()]; } /// @dev Gets the index of the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the index of the last element. function lastIndex(List storage _self) internal view returns (uint256) { uint256 _length = _self.length(); return _length.sub(1, "Vault.List: empty"); } /// @dev Gets the number of elements in the list. /// /// @return the number of elements. function length(List storage _self) internal view returns (uint256) { return _self.elements.length; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; interface ITransmuter { function distribute (address origin, uint256 amount) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; //import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {CDP} from "./libraries/alchemist/CDP.sol"; import {FixedPointMath} from "./libraries/FixedPointMath.sol"; import {ITransmuter} from "./interfaces/ITransmuter.sol"; import {IMintableERC20} from "./interfaces/IMintableERC20.sol"; import {IChainlink} from "./interfaces/IChainlink.sol"; import {IVaultAdapter} from "./interfaces/IVaultAdapter.sol"; import {Vault} from "./libraries/alchemist/Vault.sol"; import "hardhat/console.sol"; // ERC20,removing ERC20 from the alchemist // ___ __ __ _ ___ __ _ // / _ | / / ____ / / ___ __ _ (_) __ __ / _ \ ____ ___ ___ ___ ___ / /_ ___ (_) // / __ | / / / __/ / _ \/ -_) / ' \ / / \ \ / / ___/ / __// -_) (_-</ -_) / _ \/ __/ (_-< _ // /_/ |_|/_/ \__/ /_//_/\__/ /_/_/_//_/ /_\_\ /_/ /_/ \__/ /___/\__/ /_//_/\__/ /___/(_) // // ___ __ ______ __ __ _______ .___ ___. __ _______..___________. // / \ | | / || | | | | ____|| \/ | | | / || | // / ^ \ | | | ,----'| |__| | | |__ | \ / | | | | (----``---| |----` // / /_\ \ | | | | | __ | | __| | |\/| | | | \ \ | | // / _____ \ | `----.| `----.| | | | | |____ | | | | | | .----) | | | // /__/ \__\ |_______| \______||__| |__| |_______||__| |__| |__| |_______/ |__| contract Alchemist is ReentrancyGuard { using CDP for CDP.Data; using FixedPointMath for FixedPointMath.FixedDecimal; using Vault for Vault.Data; using Vault for Vault.List; using SafeERC20 for IMintableERC20; using SafeMath for uint256; using Address for address; address public constant ZERO_ADDRESS = address(0); /// @dev Resolution for all fixed point numeric parameters which represent percents. The resolution allows for a /// granularity of 0.01% increments. uint256 public constant PERCENT_RESOLUTION = 10000; /// @dev The minimum value that the collateralization limit can be set to by the governance. This is a safety rail /// to prevent the collateralization from being set to a value which breaks the system. /// /// This value is equal to 100%. /// /// IMPORTANT: This constant is a raw FixedPointMath.FixedDecimal value and assumes a resolution of 64 bits. If the /// resolution for the FixedPointMath library changes this constant must change as well. uint256 public constant MINIMUM_COLLATERALIZATION_LIMIT = 1000000000000000000; /// @dev The maximum value that the collateralization limit can be set to by the governance. This is a safety rail /// to prevent the collateralization from being set to a value which breaks the system. /// /// This value is equal to 400%. /// /// IMPORTANT: This constant is a raw FixedPointMath.FixedDecimal value and assumes a resolution of 64 bits. If the /// resolution for the FixedPointMath library changes this constant must change as well. uint256 public constant MAXIMUM_COLLATERALIZATION_LIMIT = 4000000000000000000; event GovernanceUpdated( address governance ); event PendingGovernanceUpdated( address pendingGovernance ); event SentinelUpdated( address sentinel ); event TransmuterUpdated( address transmuter ); event RewardsUpdated( address treasury ); event HarvestFeeUpdated( uint256 fee ); event CollateralizationLimitUpdated( uint256 limit ); event EmergencyExitUpdated( bool status ); event ActiveVaultUpdated( IVaultAdapter indexed adapter ); event FundsHarvested( uint256 withdrawnAmount, uint256 decreasedValue ); event FundsRecalled( uint256 indexed vaultId, uint256 withdrawnAmount, uint256 decreasedValue ); event FundsFlushed( uint256 amount ); event TokensDeposited( address indexed account, uint256 amount ); event TokensWithdrawn( address indexed account, uint256 requestedAmount, uint256 withdrawnAmount, uint256 decreasedValue ); event TokensRepaid( address indexed account, uint256 parentAmount, uint256 childAmount ); event TokensLiquidated( address indexed account, uint256 requestedAmount, uint256 withdrawnAmount, uint256 decreasedValue ); /// @dev The token that this contract is using as the parent asset. IMintableERC20 public token; /// @dev The token that this contract is using as the child asset. IMintableERC20 public xtoken; /// @dev The address of the account which currently has administrative capabilities over this contract. address public governance; /// @dev The address of the pending governance. address public pendingGovernance; /// @dev The address of the account which can initiate an emergency withdraw of funds in a vault. address public sentinel; /// @dev The address of the contract which will transmute synthetic tokens back into native tokens. address public transmuter; /// @dev The address of the contract which will receive fees. address public rewards; /// @dev The percent of each profitable harvest that will go to the rewards contract. uint256 public harvestFee; /// @dev The total amount the native token deposited into the system that is owned by external users. uint256 public totalDeposited; /// @dev when movemetns are bigger than this number flush is activated. uint256 public flushActivator; /// @dev A flag indicating if the contract has been initialized yet. bool public initialized; /// @dev A flag indicating if deposits and flushes should be halted and if all parties should be able to recall /// from the active vault. bool public emergencyExit; /// @dev The context shared between the CDPs. CDP.Context private _ctx; /// @dev A mapping of all of the user CDPs. If a user wishes to have multiple CDPs they will have to either /// create a new address or set up a proxy contract that interfaces with this contract. mapping(address => CDP.Data) private _cdps; /// @dev A list of all of the vaults. The last element of the list is the vault that is currently being used for /// deposits and withdraws. Vaults before the last element are considered inactive and are expected to be cleared. Vault.List private _vaults; /// @dev The address of the link oracle. address public _linkGasOracle; /// @dev The minimum returned amount needed to be on peg according to the oracle. uint256 public pegMinimum; constructor( IMintableERC20 _token, IMintableERC20 _xtoken, address _governance, address _sentinel ) public /*ERC20( string(abi.encodePacked("Alchemic ", _token.name())), string(abi.encodePacked("al", _token.symbol())) )*/ { require(_governance != ZERO_ADDRESS, "Alchemist: governance address cannot be 0x0."); require(_sentinel != ZERO_ADDRESS, "Alchemist: sentinel address cannot be 0x0."); token = _token; xtoken = _xtoken; governance = _governance; sentinel = _sentinel; flushActivator = 100000 ether;// change for non 18 digit tokens //_setupDecimals(_token.decimals()); uint256 COLL_LIMIT = MINIMUM_COLLATERALIZATION_LIMIT.mul(2); _ctx.collateralizationLimit = FixedPointMath.FixedDecimal(COLL_LIMIT); _ctx.accumulatedYieldWeight = FixedPointMath.FixedDecimal(0); } /// @dev Sets the pending governance. /// /// This function reverts if the new pending governance is the zero address or the caller is not the current /// governance. This is to prevent the contract governance being set to the zero address which would deadlock /// privileged contract functionality. /// /// @param _pendingGovernance the new pending governance. function setPendingGovernance(address _pendingGovernance) external onlyGov { require(_pendingGovernance != ZERO_ADDRESS, "Alchemist: governance address cannot be 0x0."); pendingGovernance = _pendingGovernance; emit PendingGovernanceUpdated(_pendingGovernance); } /// @dev Accepts the role as governance. /// /// This function reverts if the caller is not the new pending governance. function acceptGovernance() external { require(msg.sender == pendingGovernance,"sender is not pendingGovernance"); address _pendingGovernance = pendingGovernance; governance = _pendingGovernance; emit GovernanceUpdated(_pendingGovernance); } function setSentinel(address _sentinel) external onlyGov { require(_sentinel != ZERO_ADDRESS, "Alchemist: sentinel address cannot be 0x0."); sentinel = _sentinel; emit SentinelUpdated(_sentinel); } /// @dev Sets the transmuter. /// /// This function reverts if the new transmuter is the zero address or the caller is not the current governance. /// /// @param _transmuter the new transmuter. function setTransmuter(address _transmuter) external onlyGov { // Check that the transmuter address is not the zero address. Setting the transmuter to the zero address would break // transfers to the address because of `safeTransfer` checks. require(_transmuter != ZERO_ADDRESS, "Alchemist: transmuter address cannot be 0x0."); transmuter = _transmuter; emit TransmuterUpdated(_transmuter); } /// @dev Sets the flushActivator. /// /// @param _flushActivator the new flushActivator. function setFlushActivator(uint256 _flushActivator) external onlyGov { flushActivator = _flushActivator; } /// @dev Sets the rewards contract. /// /// This function reverts if the new rewards contract is the zero address or the caller is not the current governance. /// /// @param _rewards the new rewards contract. function setRewards(address _rewards) external onlyGov { // Check that the rewards address is not the zero address. Setting the rewards to the zero address would break // transfers to the address because of `safeTransfer` checks. require(_rewards != ZERO_ADDRESS, "Alchemist: rewards address cannot be 0x0."); rewards = _rewards; emit RewardsUpdated(_rewards); } /// @dev Sets the harvest fee. /// /// This function reverts if the caller is not the current governance. /// /// @param _harvestFee the new harvest fee. function setHarvestFee(uint256 _harvestFee) external onlyGov { // Check that the harvest fee is within the acceptable range. Setting the harvest fee greater than 100% could // potentially break internal logic when calculating the harvest fee. require(_harvestFee <= PERCENT_RESOLUTION, "Alchemist: harvest fee above maximum."); harvestFee = _harvestFee; emit HarvestFeeUpdated(_harvestFee); } /// @dev Sets the collateralization limit. /// /// This function reverts if the caller is not the current governance or if the collateralization limit is outside /// of the accepted bounds. /// /// @param _limit the new collateralization limit. function setCollateralizationLimit(uint256 _limit) external onlyGov { require(_limit >= MINIMUM_COLLATERALIZATION_LIMIT, "Alchemist: collateralization limit below minimum."); require(_limit <= MAXIMUM_COLLATERALIZATION_LIMIT, "Alchemist: collateralization limit above maximum."); _ctx.collateralizationLimit = FixedPointMath.FixedDecimal(_limit); emit CollateralizationLimitUpdated(_limit); } /// @dev Set oracle. function setOracleAddress(address Oracle, uint256 peg) external onlyGov { _linkGasOracle = Oracle; pegMinimum = peg; } /// @dev Sets if the contract should enter emergency exit mode. /// /// @param _emergencyExit if the contract should enter emergency exit mode. function setEmergencyExit(bool _emergencyExit) external { require(msg.sender == governance || msg.sender == sentinel, ""); emergencyExit = _emergencyExit; emit EmergencyExitUpdated(_emergencyExit); } /// @dev Gets the collateralization limit. /// /// The collateralization limit is the minimum ratio of collateral to debt that is allowed by the system. /// /// @return the collateralization limit. function collateralizationLimit() external view returns (FixedPointMath.FixedDecimal memory) { return _ctx.collateralizationLimit; } /// @dev Initializes the contract. /// /// This function checks that the transmuter and rewards have been set and sets up the active vault. /// /// @param _adapter the vault adapter of the active vault. function initialize(IVaultAdapter _adapter) external onlyGov { require(!initialized, "Alchemist: already initialized"); require(transmuter != ZERO_ADDRESS, "Alchemist: cannot initialize transmuter address to 0x0"); require(rewards != ZERO_ADDRESS, "Alchemist: cannot initialize rewards address to 0x0"); _updateActiveVault(_adapter); initialized = true; } /// @dev Migrates the system to a new vault. /// /// This function reverts if the vault adapter is the zero address, if the token that the vault adapter accepts /// is not the token that this contract defines as the parent asset, or if the contract has not yet been initialized. /// /// @param _adapter the adapter for the vault the system will migrate to. function migrate(IVaultAdapter _adapter) external expectInitialized onlyGov { _updateActiveVault(_adapter); } /// @dev Harvests yield from a vault. /// /// @param _vaultId the identifier of the vault to harvest from. /// /// @return the amount of funds that were harvested from the vault. function harvest(uint256 _vaultId) external expectInitialized returns (uint256, uint256) { Vault.Data storage _vault = _vaults.get(_vaultId); (uint256 _harvestedAmount, uint256 _decreasedValue) = _vault.harvest(address(this)); if (_harvestedAmount > 0) { uint256 _feeAmount = _harvestedAmount.mul(harvestFee).div(PERCENT_RESOLUTION); uint256 _distributeAmount = _harvestedAmount.sub(_feeAmount); FixedPointMath.FixedDecimal memory _weight = FixedPointMath.fromU256(_distributeAmount).div(totalDeposited); _ctx.accumulatedYieldWeight = _ctx.accumulatedYieldWeight.add(_weight); if (_feeAmount > 0) { token.safeTransfer(rewards, _feeAmount); } if (_distributeAmount > 0) { _distributeToTransmuter(_distributeAmount); // token.safeTransfer(transmuter, _distributeAmount); previous version call } } emit FundsHarvested(_harvestedAmount, _decreasedValue); return (_harvestedAmount, _decreasedValue); } /// @dev Recalls an amount of deposited funds from a vault to this contract. /// /// @param _vaultId the identifier of the recall funds from. /// /// @return the amount of funds that were recalled from the vault to this contract and the decreased vault value. function recall(uint256 _vaultId, uint256 _amount) external nonReentrant expectInitialized returns (uint256, uint256) { return _recallFunds(_vaultId, _amount); } /// @dev Recalls all the deposited funds from a vault to this contract. /// /// @param _vaultId the identifier of the recall funds from. /// /// @return the amount of funds that were recalled from the vault to this contract and the decreased vault value. function recallAll(uint256 _vaultId) external nonReentrant expectInitialized returns (uint256, uint256) { Vault.Data storage _vault = _vaults.get(_vaultId); return _recallFunds(_vaultId, _vault.totalDeposited); } /// @dev Flushes buffered tokens to the active vault. /// /// This function reverts if an emergency exit is active. This is in place to prevent the potential loss of /// additional funds. /// /// @return the amount of tokens flushed to the active vault. function flush() external nonReentrant expectInitialized returns (uint256) { // Prevent flushing to the active vault when an emergency exit is enabled to prevent potential loss of funds if // the active vault is poisoned for any reason. require(!emergencyExit, "emergency pause enabled"); return flushActiveVault(); } /// @dev Internal function to flush buffered tokens to the active vault. /// /// This function reverts if an emergency exit is active. This is in place to prevent the potential loss of /// additional funds. /// /// @return the amount of tokens flushed to the active vault. function flushActiveVault() internal returns (uint256) { Vault.Data storage _activeVault = _vaults.last(); uint256 _depositedAmount = _activeVault.depositAll(); emit FundsFlushed(_depositedAmount); return _depositedAmount; } /// @dev Deposits collateral into a CDP. /// /// This function reverts if an emergency exit is active. This is in place to prevent the potential loss of /// additional funds. /// /// @param _amount the amount of collateral to deposit. function deposit(uint256 _amount) external nonReentrant noContractAllowed expectInitialized { require(!emergencyExit, "emergency pause enabled"); CDP.Data storage _cdp = _cdps[msg.sender]; _cdp.update(_ctx); token.safeTransferFrom(msg.sender, address(this), _amount); if(_amount >= flushActivator) { flushActiveVault(); } totalDeposited = totalDeposited.add(_amount); _cdp.totalDeposited = _cdp.totalDeposited.add(_amount); _cdp.lastDeposit = block.number; emit TokensDeposited(msg.sender, _amount); } /// @dev Attempts to withdraw part of a CDP's collateral. /// /// This function reverts if a deposit into the CDP was made in the same block. This is to prevent flash loan attacks /// on other internal or external systems. /// /// @param _amount the amount of collateral to withdraw. function withdraw(uint256 _amount) external nonReentrant noContractAllowed expectInitialized returns (uint256, uint256) { CDP.Data storage _cdp = _cdps[msg.sender]; require(block.number > _cdp.lastDeposit, ""); _cdp.update(_ctx); (uint256 _withdrawnAmount, uint256 _decreasedValue) = _withdrawFundsTo(msg.sender, _amount); _cdp.totalDeposited = _cdp.totalDeposited.sub(_decreasedValue, "Exceeds withdrawable amount"); _cdp.checkHealth(_ctx, "Action blocked: unhealthy collateralization ratio"); if(_amount >= flushActivator) { flushActiveVault(); } emit TokensWithdrawn(msg.sender, _amount, _withdrawnAmount, _decreasedValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Repays debt with the native and or synthetic token. /// /// An approval is required to transfer native tokens to the transmuter. function repay(uint256 _parentAmount, uint256 _childAmount) external nonReentrant noContractAllowed onLinkCheck expectInitialized { CDP.Data storage _cdp = _cdps[msg.sender]; _cdp.update(_ctx); if (_parentAmount > 0) { token.safeTransferFrom(msg.sender, address(this), _parentAmount); _distributeToTransmuter(_parentAmount); } if (_childAmount > 0) { xtoken.burnFrom(msg.sender, _childAmount); //lower debt cause burn xtoken.lowerHasMinted(_childAmount); } uint256 _totalAmount = _parentAmount.add(_childAmount); _cdp.totalDebt = _cdp.totalDebt.sub(_totalAmount, ""); emit TokensRepaid(msg.sender, _parentAmount, _childAmount); } /// @dev Attempts to liquidate part of a CDP's collateral to pay back its debt. /// /// @param _amount the amount of collateral to attempt to liquidate. function liquidate(uint256 _amount) external nonReentrant noContractAllowed onLinkCheck expectInitialized returns (uint256, uint256) { CDP.Data storage _cdp = _cdps[msg.sender]; _cdp.update(_ctx); // don't attempt to liquidate more than is possible if(_amount > _cdp.totalDebt){ _amount = _cdp.totalDebt; } (uint256 _withdrawnAmount, uint256 _decreasedValue) = _withdrawFundsTo(address(this), _amount); //changed to new transmuter compatibillity _distributeToTransmuter(_withdrawnAmount); _cdp.totalDeposited = _cdp.totalDeposited.sub(_decreasedValue, ""); _cdp.totalDebt = _cdp.totalDebt.sub(_withdrawnAmount, ""); emit TokensLiquidated(msg.sender, _amount, _withdrawnAmount, _decreasedValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Mints synthetic tokens by either claiming credit or increasing the debt. /// /// Claiming credit will take priority over increasing the debt. /// /// This function reverts if the debt is increased and the CDP health check fails. /// /// @param _amount the amount of alchemic tokens to borrow. function mint(uint256 _amount) external nonReentrant noContractAllowed onLinkCheck expectInitialized { CDP.Data storage _cdp = _cdps[msg.sender]; _cdp.update(_ctx); uint256 _totalCredit = _cdp.totalCredit; if (_totalCredit < _amount) { uint256 _remainingAmount = _amount.sub(_totalCredit); _cdp.totalDebt = _cdp.totalDebt.add(_remainingAmount); _cdp.totalCredit = 0; _cdp.checkHealth(_ctx, "Alchemist: Loan-to-value ratio breached"); } else { _cdp.totalCredit = _totalCredit.sub(_amount); } xtoken.mint(msg.sender, _amount); if(_amount >= flushActivator) { flushActiveVault(); } } /// @dev Gets the number of vaults in the vault list. /// /// @return the vault count. function vaultCount() external view returns (uint256) { return _vaults.length(); } /// @dev Get the adapter of a vault. /// /// @param _vaultId the identifier of the vault. /// /// @return the vault adapter. function getVaultAdapter(uint256 _vaultId) external view returns (IVaultAdapter) { Vault.Data storage _vault = _vaults.get(_vaultId); return _vault.adapter; } /// @dev Get the total amount of the parent asset that has been deposited into a vault. /// /// @param _vaultId the identifier of the vault. /// /// @return the total amount of deposited tokens. function getVaultTotalDeposited(uint256 _vaultId) external view returns (uint256) { Vault.Data storage _vault = _vaults.get(_vaultId); return _vault.totalDeposited; } /// @dev Get the total amount of collateral deposited into a CDP. /// /// @param _account the user account of the CDP to query. /// /// @return the deposited amount of tokens. function getCdpTotalDeposited(address _account) external view returns (uint256) { CDP.Data storage _cdp = _cdps[_account]; return _cdp.totalDeposited; } /// @dev Get the total amount of alchemic tokens borrowed from a CDP. /// /// @param _account the user account of the CDP to query. /// /// @return the borrowed amount of tokens. function getCdpTotalDebt(address _account) external view returns (uint256) { CDP.Data storage _cdp = _cdps[_account]; return _cdp.getUpdatedTotalDebt(_ctx); } /// @dev Get the total amount of credit that a CDP has. /// /// @param _account the user account of the CDP to query. /// /// @return the amount of credit. function getCdpTotalCredit(address _account) external view returns (uint256) { CDP.Data storage _cdp = _cdps[_account]; return _cdp.getUpdatedTotalCredit(_ctx); } /// @dev Gets the last recorded block of when a user made a deposit into their CDP. /// /// @param _account the user account of the CDP to query. /// /// @return the block number of the last deposit. function getCdpLastDeposit(address _account) external view returns (uint256) { CDP.Data storage _cdp = _cdps[_account]; return _cdp.lastDeposit; } /// @dev sends tokens to the transmuter /// /// benefit of great nation of transmuter function _distributeToTransmuter(uint256 amount) internal { token.approve(transmuter,amount); ITransmuter(transmuter).distribute(address(this),amount); // lower debt cause of 'burn' xtoken.lowerHasMinted(amount); } /// @dev Checks that parent token is on peg. /// /// This is used over a modifier limit of pegged interactions. modifier onLinkCheck() { if(pegMinimum > 0 ){ uint256 oracleAnswer = uint256(IChainlink(_linkGasOracle).latestAnswer()); require(oracleAnswer > pegMinimum, "off peg limitation"); } _; } /// @dev Checks that caller is not a eoa. /// /// This is used to prevent contracts from interacting. modifier noContractAllowed() { require(!address(msg.sender).isContract() && msg.sender == tx.origin, "Sorry we do not accept contract!"); _; } /// @dev Checks that the contract is in an initialized state. /// /// This is used over a modifier to reduce the size of the contract modifier expectInitialized() { require(initialized, "Alchemist: not initialized."); _; } /// @dev Checks that the current message sender or caller is a specific address. /// /// @param _expectedCaller the expected caller. function _expectCaller(address _expectedCaller) internal { require(msg.sender == _expectedCaller, ""); } /// @dev Checks that the current message sender or caller is the governance address. /// /// modifier onlyGov() { require(msg.sender == governance, "Alchemist: only governance."); _; } /// @dev Updates the active vault. /// /// This function reverts if the vault adapter is the zero address, if the token that the vault adapter accepts /// is not the token that this contract defines as the parent asset, or if the contract has not yet been initialized. /// /// @param _adapter the adapter for the new active vault. function _updateActiveVault(IVaultAdapter _adapter) internal { require(_adapter != IVaultAdapter(ZERO_ADDRESS), "Alchemist: active vault address cannot be 0x0."); require(_adapter.token() == token, "Alchemist: token mismatch."); _vaults.push(Vault.Data({ adapter: _adapter, totalDeposited: 0 })); emit ActiveVaultUpdated(_adapter); } /// @dev Recalls an amount of funds from a vault to this contract. /// /// @param _vaultId the identifier of the recall funds from. /// @param _amount the amount of funds to recall from the vault. /// /// @return the amount of funds that were recalled from the vault to this contract and the decreased vault value. function _recallFunds(uint256 _vaultId, uint256 _amount) internal returns (uint256, uint256) { require(emergencyExit || msg.sender == governance || _vaultId != _vaults.lastIndex(), "Alchemist: not an emergency, not governance, and user does not have permission to recall funds from active vault"); Vault.Data storage _vault = _vaults.get(_vaultId); (uint256 _withdrawnAmount, uint256 _decreasedValue) = _vault.withdraw(address(this), _amount); emit FundsRecalled(_vaultId, _withdrawnAmount, _decreasedValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Attempts to withdraw funds from the active vault to the recipient. /// /// Funds will be first withdrawn from this contracts balance and then from the active vault. This function /// is different from `recallFunds` in that it reduces the total amount of deposited tokens by the decreased /// value of the vault. /// /// @param _recipient the account to withdraw the funds to. /// @param _amount the amount of funds to withdraw. function _withdrawFundsTo(address _recipient, uint256 _amount) internal returns (uint256, uint256) { // Pull the funds from the buffer. uint256 _bufferedAmount = Math.min(_amount, token.balanceOf(address(this))); if (_recipient != address(this)) { token.safeTransfer(_recipient, _bufferedAmount); } uint256 _totalWithdrawn = _bufferedAmount; uint256 _totalDecreasedValue = _bufferedAmount; uint256 _remainingAmount = _amount.sub(_bufferedAmount); // Pull the remaining funds from the active vault. if (_remainingAmount > 0) { Vault.Data storage _activeVault = _vaults.last(); (uint256 _withdrawAmount, uint256 _decreasedValue) = _activeVault.withdraw( _recipient, _remainingAmount ); _totalWithdrawn = _totalWithdrawn.add(_withdrawAmount); _totalDecreasedValue = _totalDecreasedValue.add(_decreasedValue); } totalDeposited = totalDeposited.sub(_totalDecreasedValue); return (_totalWithdrawn, _totalDecreasedValue); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../FixedPointMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; import "hardhat/console.sol"; /// @title CDP /// /// @dev A library which provides the CDP data struct and associated functions. library CDP { using CDP for Data; using FixedPointMath for FixedPointMath.FixedDecimal; using SafeERC20 for IDetailedERC20; using SafeMath for uint256; struct Context { FixedPointMath.FixedDecimal collateralizationLimit; FixedPointMath.FixedDecimal accumulatedYieldWeight; } struct Data { uint256 totalDeposited; uint256 totalDebt; uint256 totalCredit; uint256 lastDeposit; FixedPointMath.FixedDecimal lastAccumulatedYieldWeight; } function update(Data storage _self, Context storage _ctx) internal { uint256 _earnedYield = _self.getEarnedYield(_ctx); if (_earnedYield > _self.totalDebt) { uint256 _currentTotalDebt = _self.totalDebt; _self.totalDebt = 0; _self.totalCredit = _earnedYield.sub(_currentTotalDebt); } else { _self.totalDebt = _self.totalDebt.sub(_earnedYield); } _self.lastAccumulatedYieldWeight = _ctx.accumulatedYieldWeight; } /// @dev Assures that the CDP is healthy. /// /// This function will revert if the CDP is unhealthy. function checkHealth(Data storage _self, Context storage _ctx, string memory _msg) internal view { require(_self.isHealthy(_ctx), _msg); } /// @dev Gets if the CDP is considered healthy. /// /// A CDP is healthy if its collateralization ratio is greater than the global collateralization limit. /// /// @return if the CDP is healthy. function isHealthy(Data storage _self, Context storage _ctx) internal view returns (bool) { return _ctx.collateralizationLimit.cmp(_self.getCollateralizationRatio(_ctx)) <= 0; } function getUpdatedTotalDebt(Data storage _self, Context storage _ctx) internal view returns (uint256) { uint256 _unclaimedYield = _self.getEarnedYield(_ctx); if (_unclaimedYield == 0) { return _self.totalDebt; } uint256 _currentTotalDebt = _self.totalDebt; if (_unclaimedYield >= _currentTotalDebt) { return 0; } return _currentTotalDebt - _unclaimedYield; } function getUpdatedTotalCredit(Data storage _self, Context storage _ctx) internal view returns (uint256) { uint256 _unclaimedYield = _self.getEarnedYield(_ctx); if (_unclaimedYield == 0) { return _self.totalCredit; } uint256 _currentTotalDebt = _self.totalDebt; if (_unclaimedYield <= _currentTotalDebt) { return 0; } return _self.totalCredit + (_unclaimedYield - _currentTotalDebt); } /// @dev Gets the amount of yield that a CDP has earned since the last time it was updated. /// /// @param _self the CDP to query. /// @param _ctx the CDP context. /// /// @return the amount of earned yield. function getEarnedYield(Data storage _self, Context storage _ctx) internal view returns (uint256) { FixedPointMath.FixedDecimal memory _currentAccumulatedYieldWeight = _ctx.accumulatedYieldWeight; FixedPointMath.FixedDecimal memory _lastAccumulatedYieldWeight = _self.lastAccumulatedYieldWeight; if (_currentAccumulatedYieldWeight.cmp(_lastAccumulatedYieldWeight) == 0) { return 0; } return _currentAccumulatedYieldWeight .sub(_lastAccumulatedYieldWeight) .mul(_self.totalDeposited) .decode(); } /// @dev Gets a CDPs collateralization ratio. /// /// The collateralization ratio is defined as the ratio of collateral to debt. If the CDP has zero debt then this /// will return the maximum value of a fixed point integer. /// /// This function will use the updated total debt so an update before calling this function is not required. /// /// @param _self the CDP to query. /// /// @return a fixed point integer representing the collateralization ratio. function getCollateralizationRatio(Data storage _self, Context storage _ctx) internal view returns (FixedPointMath.FixedDecimal memory) { uint256 _totalDebt = _self.getUpdatedTotalDebt(_ctx); if (_totalDebt == 0) { return FixedPointMath.maximumValue(); } return FixedPointMath.fromU256(_self.totalDeposited).div(_totalDebt); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {IDetailedERC20} from "./IDetailedERC20.sol"; interface IMintableERC20 is IDetailedERC20{ function mint(address _recipient, uint256 _amount) external; function burnFrom(address account, uint256 amount) external; function lowerHasMinted(uint256 amount)external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; interface IChainlink { function latestAnswer() external view returns (int256); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; //import "hardhat/console.sol"; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; import {IVaultAdapter} from "../../interfaces/IVaultAdapter.sol"; import "hardhat/console.sol"; /// @title Pool /// /// @dev A library which provides the Vault data struct and associated functions. library Vault { using Vault for Data; using Vault for List; using SafeERC20 for IDetailedERC20; using SafeMath for uint256; struct Data { IVaultAdapter adapter; uint256 totalDeposited; } struct List { Data[] elements; } /// @dev Gets the total amount of assets deposited in the vault. /// /// @return the total assets. function totalValue(Data storage _self) internal view returns (uint256) { return _self.adapter.totalValue(); } /// @dev Gets the token that the vault accepts. /// /// @return the accepted token. function token(Data storage _self) internal view returns (IDetailedERC20) { return IDetailedERC20(_self.adapter.token()); } /// @dev Deposits funds from the caller into the vault. /// /// @param _amount the amount of funds to deposit. function deposit(Data storage _self, uint256 _amount) internal returns (uint256) { // Push the token that the vault accepts onto the stack to save gas. IDetailedERC20 _token = _self.token(); _token.safeTransfer(address(_self.adapter), _amount); _self.adapter.deposit(_amount); _self.totalDeposited = _self.totalDeposited.add(_amount); return _amount; } /// @dev Deposits the entire token balance of the caller into the vault. function depositAll(Data storage _self) internal returns (uint256) { IDetailedERC20 _token = _self.token(); return _self.deposit(_token.balanceOf(address(this))); } /// @dev Withdraw deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. /// @param _amount the amount of tokens to withdraw. function withdraw(Data storage _self, address _recipient, uint256 _amount) internal returns (uint256, uint256) { (uint256 _withdrawnAmount, uint256 _decreasedValue) = _self.directWithdraw(_recipient, _amount); _self.totalDeposited = _self.totalDeposited.sub(_decreasedValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Directly withdraw deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. /// @param _amount the amount of tokens to withdraw. function directWithdraw(Data storage _self, address _recipient, uint256 _amount) internal returns (uint256, uint256) { IDetailedERC20 _token = _self.token(); uint256 _startingBalance = _token.balanceOf(_recipient); uint256 _startingTotalValue = _self.totalValue(); _self.adapter.withdraw(_recipient, _amount); uint256 _endingBalance = _token.balanceOf(_recipient); uint256 _withdrawnAmount = _endingBalance.sub(_startingBalance); uint256 _endingTotalValue = _self.totalValue(); uint256 _decreasedValue = _startingTotalValue.sub(_endingTotalValue); return (_withdrawnAmount, _decreasedValue); } /// @dev Withdraw all the deposited funds from the vault. /// /// @param _recipient the account to withdraw the tokens to. function withdrawAll(Data storage _self, address _recipient) internal returns (uint256, uint256) { return _self.withdraw(_recipient, _self.totalDeposited); } /// @dev Harvests yield from the vault. /// /// @param _recipient the account to withdraw the harvested yield to. function harvest(Data storage _self, address _recipient) internal returns (uint256, uint256) { if (_self.totalValue() <= _self.totalDeposited) { return (0, 0); } uint256 _withdrawAmount = _self.totalValue().sub(_self.totalDeposited); return _self.directWithdraw(_recipient, _withdrawAmount); } /// @dev Adds a element to the list. /// /// @param _element the element to add. function push(List storage _self, Data memory _element) internal { _self.elements.push(_element); } /// @dev Gets a element from the list. /// /// @param _index the index in the list. /// /// @return the element at the specified index. function get(List storage _self, uint256 _index) internal view returns (Data storage) { return _self.elements[_index]; } /// @dev Gets the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the last element in the list. function last(List storage _self) internal view returns (Data storage) { return _self.elements[_self.lastIndex()]; } /// @dev Gets the index of the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the index of the last element. function lastIndex(List storage _self) internal view returns (uint256) { uint256 _length = _self.length(); return _length.sub(1, "Vault.List: empty"); } /// @dev Gets the number of elements in the list. /// /// @return the number of elements. function length(List storage _self) internal view returns (uint256) { return _self.elements.length; } } pragma solidity 0.6.12; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./interfaces/IERC20Burnable.sol"; import "hardhat/console.sol"; // ___ __ __ _ ___ __ _ // / _ | / / ____ / / ___ __ _ (_) __ __ / _ \ ____ ___ ___ ___ ___ / /_ ___ (_) // / __ | / / / __/ / _ \/ -_) / ' \ / / \ \ / / ___/ / __// -_) (_-</ -_) / _ \/ __/ (_-< _ // /_/ |_|/_/ \__/ /_//_/\__/ /_/_/_//_/ /_\_\ /_/ /_/ \__/ /___/\__/ /_//_/\__/ /___/(_) // // .___________..______ ___ .__ __. _______..___ ___. __ __ .___________. _______ .______ // | || _ \ / \ | \ | | / || \/ | | | | | | || ____|| _ \ // `---| |----`| |_) | / ^ \ | \| | | (----`| \ / | | | | | `---| |----`| |__ | |_) | // | | | / / /_\ \ | . ` | \ \ | |\/| | | | | | | | | __| | / // | | | |\ \----. / _____ \ | |\ | .----) | | | | | | `--' | | | | |____ | |\ \----. // |__| | _| `._____|/__/ \__\ |__| \__| |_______/ |__| |__| \______/ |__| |_______|| _| `._____| /** * @dev Implementation of the {IERC20Burnable} 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 {IERC20Burnable-approve}. */ contract Transmuter is Context { using SafeMath for uint256; using SafeERC20 for IERC20Burnable; using Address for address; address public constant ZERO_ADDRESS = address(0); uint256 public TRANSMUTATION_PERIOD; address public AlToken; address public Token; mapping(address => uint256) public depositedAlTokens; mapping(address => uint256) public tokensInBucket; mapping(address => uint256) public realisedTokens; mapping(address => uint256) public lastDividendPoints; mapping(address => bool) public userIsKnown; mapping(uint256 => address) public userList; uint256 public nextUser; uint256 public totalSupplyAltokens; uint256 public buffer; uint256 public lastDepositBlock; ///@dev values needed to calculate the distribution of base asset in proportion for alTokens staked uint256 public pointMultiplier = 10e18; uint256 public totalDividendPoints; uint256 public unclaimedDividends; /// @dev alchemist addresses whitelisted mapping (address => bool) public whiteList; /// @dev The address of the account which currently has administrative capabilities over this contract. address public governance; /// @dev The address of the pending governance. address public pendingGovernance; event GovernanceUpdated( address governance ); event PendingGovernanceUpdated( address pendingGovernance ); event TransmuterPeriodUpdated( uint256 newTransmutationPeriod ); constructor(address _AlToken, address _Token, address _governance) public { require(_governance != ZERO_ADDRESS, "Transmuter: 0 gov"); governance = _governance; AlToken = _AlToken; Token = _Token; TRANSMUTATION_PERIOD = 50; } ///@return displays the user's share of the pooled alTokens. function dividendsOwing(address account) public view returns (uint256) { uint256 newDividendPoints = totalDividendPoints.sub(lastDividendPoints[account]); return depositedAlTokens[account].mul(newDividendPoints).div(pointMultiplier); } ///@dev modifier to fill the bucket and keep bookkeeping correct incase of increase/decrease in shares modifier updateAccount(address account) { uint256 owing = dividendsOwing(account); if (owing > 0) { unclaimedDividends = unclaimedDividends.sub(owing); tokensInBucket[account] = tokensInBucket[account].add(owing); } lastDividendPoints[account] = totalDividendPoints; _; } ///@dev modifier add users to userlist. Users are indexed in order to keep track of when a bond has been filled modifier checkIfNewUser() { if (!userIsKnown[msg.sender]) { userList[nextUser] = msg.sender; userIsKnown[msg.sender] = true; nextUser++; } _; } ///@dev run the phased distribution of the buffered funds modifier runPhasedDistribution() { uint256 _lastDepositBlock = lastDepositBlock; uint256 _currentBlock = block.number; uint256 _toDistribute = 0; uint256 _buffer = buffer; // check if there is something in bufffer if (_buffer > 0) { // NOTE: if last deposit was updated in the same block as the current call // then the below logic gates will fail //calculate diffrence in time uint256 deltaTime = _currentBlock.sub(_lastDepositBlock); // distribute all if bigger than timeframe if(deltaTime >= TRANSMUTATION_PERIOD) { _toDistribute = _buffer; } else { //needs to be bigger than 0 cuzz solidity no decimals if(_buffer.mul(deltaTime) > TRANSMUTATION_PERIOD) { _toDistribute = _buffer.mul(deltaTime).div(TRANSMUTATION_PERIOD); } } // factually allocate if any needs distribution if(_toDistribute > 0){ // remove from buffer buffer = _buffer.sub(_toDistribute); // increase the allocation increaseAllocations(_toDistribute); } } // current timeframe is now the last lastDepositBlock = _currentBlock; _; } /// @dev A modifier which checks if whitelisted for minting. modifier onlyWhitelisted() { require(whiteList[msg.sender], "Transmuter: !whitelisted"); _; } /// @dev Checks that the current message sender or caller is the governance address. /// /// modifier onlyGov() { require(msg.sender == governance, "Transmuter: !governance"); _; } ///@dev set the TRANSMUTATION_PERIOD variable /// /// sets the length (in blocks) of one full distribution phase function setTransmutationPeriod(uint256 newTransmutationPeriod) public onlyGov() { TRANSMUTATION_PERIOD = newTransmutationPeriod; emit TransmuterPeriodUpdated(TRANSMUTATION_PERIOD); } ///@dev claims the base token after it has been transmuted /// ///This function reverts if there is no realisedToken balance function claim() public { address sender = msg.sender; require(realisedTokens[sender] > 0); uint256 value = realisedTokens[sender]; realisedTokens[sender] = 0; IERC20Burnable(Token).safeTransfer(sender, value); } ///@dev Withdraws staked alTokens from the transmuter /// /// This function reverts if you try to draw more tokens than you deposited /// ///@param amount the amount of alTokens to unstake function unstake(uint256 amount) public updateAccount(msg.sender) { // by calling this function before transmuting you forfeit your gained allocation address sender = msg.sender; require(depositedAlTokens[sender] >= amount,"Transmuter: unstake amount exceeds deposited amount"); depositedAlTokens[sender] = depositedAlTokens[sender].sub(amount); totalSupplyAltokens = totalSupplyAltokens.sub(amount); IERC20Burnable(AlToken).safeTransfer(sender, amount); } ///@dev Deposits alTokens into the transmuter /// ///@param amount the amount of alTokens to stake function stake(uint256 amount) public runPhasedDistribution() updateAccount(msg.sender) checkIfNewUser() { // requires approval of AlToken first address sender = msg.sender; //require tokens transferred in; IERC20Burnable(AlToken).safeTransferFrom(sender, address(this), amount); totalSupplyAltokens = totalSupplyAltokens.add(amount); depositedAlTokens[sender] = depositedAlTokens[sender].add(amount); } /// @dev Converts the staked alTokens to the base tokens in amount of the sum of pendingdivs and tokensInBucket /// /// once the alToken has been converted, it is burned, and the base token becomes realisedTokens which can be recieved using claim() /// /// reverts if there are no pendingdivs or tokensInBucket function transmute() public runPhasedDistribution() updateAccount(msg.sender) { address sender = msg.sender; uint256 pendingz = tokensInBucket[sender]; uint256 diff; require(pendingz > 0, "need to have pending in bucket"); tokensInBucket[sender] = 0; // check bucket overflow if (pendingz > depositedAlTokens[sender]) { diff = pendingz.sub(depositedAlTokens[sender]); // remove overflow pendingz = depositedAlTokens[sender]; } // decrease altokens depositedAlTokens[sender] = depositedAlTokens[sender].sub(pendingz); // BURN ALTOKENS IERC20Burnable(AlToken).burn(pendingz); // adjust total totalSupplyAltokens = totalSupplyAltokens.sub(pendingz); // reallocate overflow increaseAllocations(diff); // add payout realisedTokens[sender] = realisedTokens[sender].add(pendingz); } /// @dev Executes transmute() on another account that has had more base tokens allocated to it than alTokens staked. /// /// The caller of this function will have the surlus base tokens credited to their tokensInBucket balance, rewarding them for performing this action /// /// This function reverts if the address to transmute is not over-filled. /// /// @param toTransmute address of the account you will force transmute. function forceTransmute(address toTransmute) public runPhasedDistribution() updateAccount(msg.sender) updateAccount(toTransmute) { //load into memory address sender = msg.sender; uint256 pendingz = tokensInBucket[toTransmute]; // check restrictions require( pendingz > depositedAlTokens[toTransmute], "Transmuter: !overflow" ); // empty bucket tokensInBucket[toTransmute] = 0; // calculaate diffrence uint256 diff = pendingz.sub(depositedAlTokens[toTransmute]); // remove overflow pendingz = depositedAlTokens[toTransmute]; // decrease altokens depositedAlTokens[toTransmute] = 0; // BURN ALTOKENS IERC20Burnable(AlToken).burn(pendingz); // adjust total totalSupplyAltokens = totalSupplyAltokens.sub(pendingz); // reallocate overflow tokensInBucket[sender] = tokensInBucket[sender].add(diff); // add payout realisedTokens[toTransmute] = realisedTokens[toTransmute].add(pendingz); // force payout of realised tokens of the toTransmute address if (realisedTokens[toTransmute] > 0) { uint256 value = realisedTokens[toTransmute]; realisedTokens[toTransmute] = 0; IERC20Burnable(Token).safeTransfer(toTransmute, value); } } /// @dev Transmutes and unstakes all alTokens /// /// This function combines the transmute and unstake functions for ease of use function exit() public { transmute(); uint256 toWithdraw = depositedAlTokens[msg.sender]; unstake(toWithdraw); } /// @dev Transmutes and claims all converted base tokens. /// /// This function combines the transmute and claim functions while leaving your remaining alTokens staked. function transmuteAndClaim() public { transmute(); claim(); } /// @dev Transmutes, claims base tokens, and withdraws alTokens. /// /// This function helps users to exit the transmuter contract completely after converting their alTokens to the base pair. function transmuteClaimAndWithdraw() public { transmute(); claim(); uint256 toWithdraw = depositedAlTokens[msg.sender]; unstake(toWithdraw); } /// @dev Distributes the base token proportionally to all alToken stakers. /// /// This function is meant to be called by the Alchemist contract for when it is sending yield to the transmuter. /// Anyone can call this and add funds, idk why they would do that though... /// /// @param origin the account that is sending the tokens to be distributed. /// @param amount the amount of base tokens to be distributed to the transmuter. function distribute(address origin, uint256 amount) public onlyWhitelisted() runPhasedDistribution() { IERC20Burnable(Token).safeTransferFrom(origin, address(this), amount); buffer = buffer.add(amount); } /// @dev Allocates the incoming yield proportionally to all alToken stakers. /// /// @param amount the amount of base tokens to be distributed in the transmuter. function increaseAllocations(uint256 amount) internal { if(totalSupplyAltokens > 0 && amount > 0) { totalDividendPoints = totalDividendPoints.add( amount.mul(pointMultiplier).div(totalSupplyAltokens) ); unclaimedDividends = unclaimedDividends.add(amount); } else { buffer = buffer.add(amount); } } /// @dev Gets the status of a user's staking position. /// /// The total amount allocated to a user is the sum of pendingdivs and inbucket. /// /// @param user the address of the user you wish to query. /// /// returns user status function userInfo(address user) public view returns ( uint256 depositedAl, uint256 pendingdivs, uint256 inbucket, uint256 realised ) { uint256 _depositedAl = depositedAlTokens[user]; uint256 _toDistribute = buffer.mul(block.number.sub(lastDepositBlock)).div(TRANSMUTATION_PERIOD); if(block.number.sub(lastDepositBlock) > TRANSMUTATION_PERIOD){ _toDistribute = buffer; } uint256 _pendingdivs = _toDistribute.mul(depositedAlTokens[user]).div(totalSupplyAltokens); uint256 _inbucket = tokensInBucket[user].add(dividendsOwing(user)); uint256 _realised = realisedTokens[user]; return (_depositedAl, _pendingdivs, _inbucket, _realised); } /// @dev Gets the status of multiple users in one call /// /// This function is used to query the contract to check for /// accounts that have overfilled positions in order to check /// who can be force transmuted. /// /// @param from the first index of the userList /// @param to the last index of the userList /// /// returns the userList with their staking status in paginated form. function getMultipleUserInfo(uint256 from, uint256 to) public view returns (address[] memory theUserList, uint256[] memory theUserData) { uint256 i = from; uint256 delta = to - from; address[] memory _theUserList = new address[](delta); //user uint256[] memory _theUserData = new uint256[](delta * 2); //deposited-bucket uint256 y = 0; uint256 _toDistribute = buffer.mul(block.number.sub(lastDepositBlock)).div(TRANSMUTATION_PERIOD); if(block.number.sub(lastDepositBlock) > TRANSMUTATION_PERIOD){ _toDistribute = buffer; } for (uint256 x = 0; x < delta; x += 1) { _theUserList[x] = userList[i]; _theUserData[y] = depositedAlTokens[userList[i]]; _theUserData[y + 1] = dividendsOwing(userList[i]).add(tokensInBucket[userList[i]]).add(_toDistribute.mul(depositedAlTokens[userList[i]]).div(totalSupplyAltokens)); y += 2; i += 1; } return (_theUserList, _theUserData); } /// @dev Gets info on the buffer /// /// This function is used to query the contract to get the /// latest state of the buffer /// /// @return _toDistribute the amount ready to be distributed /// @return _deltaBlocks the amount of time since the last phased distribution /// @return _buffer the amount in the buffer function bufferInfo() public view returns (uint256 _toDistribute, uint256 _deltaBlocks, uint256 _buffer){ _deltaBlocks = block.number.sub(lastDepositBlock); _buffer = buffer; _toDistribute = _buffer.mul(_deltaBlocks).div(TRANSMUTATION_PERIOD); } /// @dev Sets the pending governance. /// /// This function reverts if the new pending governance is the zero address or the caller is not the current /// governance. This is to prevent the contract governance being set to the zero address which would deadlock /// privileged contract functionality. /// /// @param _pendingGovernance the new pending governance. function setPendingGovernance(address _pendingGovernance) external onlyGov { require(_pendingGovernance != ZERO_ADDRESS, "Transmuter: 0 gov"); pendingGovernance = _pendingGovernance; emit PendingGovernanceUpdated(_pendingGovernance); } /// @dev Accepts the role as governance. /// /// This function reverts if the caller is not the new pending governance. function acceptGovernance() external { require(msg.sender == pendingGovernance,"!pendingGovernance"); address _pendingGovernance = pendingGovernance; governance = _pendingGovernance; emit GovernanceUpdated(_pendingGovernance); } /// This function reverts if the caller is not governance /// /// @param _toWhitelist the account to mint tokens to. /// @param _state the whitelist state. function setWhitelist(address _toWhitelist, bool _state) external onlyGov { whiteList[_toWhitelist] = _state; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; //import "hardhat/console.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {FixedPointMath} from "./libraries/FixedPointMath.sol"; import {IMintableERC20} from "./interfaces/IMintableERC20.sol"; import {Pool} from "./libraries/pools/Pool.sol"; import {Stake} from "./libraries/pools/Stake.sol"; import {StakingPools} from "./StakingPools.sol"; import "hardhat/console.sol"; /// @title StakingPools // ___ __ __ _ ___ __ _ // / _ | / / ____ / / ___ __ _ (_) __ __ / _ \ ____ ___ ___ ___ ___ / /_ ___ (_) // / __ | / / / __/ / _ \/ -_) / ' \ / / \ \ / / ___/ / __// -_) (_-</ -_) / _ \/ __/ (_-< _ // /_/ |_|/_/ \__/ /_//_/\__/ /_/_/_//_/ /_\_\ /_/ /_/ \__/ /___/\__/ /_//_/\__/ /___/(_) // // _______..___________. ___ __ ___ __ .__ __. _______ .______ ______ ______ __ _______. // / || | / \ | |/ / | | | \ | | / _____| | _ \ / __ \ / __ \ | | / | // | (----``---| |----` / ^ \ | ' / | | | \| | | | __ | |_) | | | | | | | | | | | | (----` // \ \ | | / /_\ \ | < | | | . ` | | | |_ | | ___/ | | | | | | | | | | \ \ // .----) | | | / _____ \ | . \ | | | |\ | | |__| | | | | `--' | | `--' | | `----..----) | // |_______/ |__| /__/ \__\ |__|\__\ |__| |__| \__| \______| | _| \______/ \______/ |_______||_______/ /// /// @dev A contract which allows users to stake to farm tokens. /// /// This contract was inspired by Chef Nomi's 'MasterChef' contract which can be found in this /// repository: https://github.com/sushiswap/sushiswap. contract StakingPools is ReentrancyGuard { using FixedPointMath for FixedPointMath.FixedDecimal; using Pool for Pool.Data; using Pool for Pool.List; using SafeERC20 for IERC20; using SafeMath for uint256; using Stake for Stake.Data; event PendingGovernanceUpdated( address pendingGovernance ); event GovernanceUpdated( address governance ); event RewardRateUpdated( uint256 rewardRate ); event PoolRewardWeightUpdated( uint256 indexed poolId, uint256 rewardWeight ); event PoolCreated( uint256 indexed poolId, IERC20 indexed token ); event TokensDeposited( address indexed user, uint256 indexed poolId, uint256 amount ); event TokensWithdrawn( address indexed user, uint256 indexed poolId, uint256 amount ); event TokensClaimed( address indexed user, uint256 indexed poolId, uint256 amount ); /// @dev The token which will be minted as a reward for staking. IMintableERC20 public reward; /// @dev The address of the account which currently has administrative capabilities over this contract. address public governance; address public pendingGovernance; /// @dev Tokens are mapped to their pool identifier plus one. Tokens that do not have an associated pool /// will return an identifier of zero. mapping(IERC20 => uint256) public tokenPoolIds; /// @dev The context shared between the pools. Pool.Context private _ctx; /// @dev A list of all of the pools. Pool.List private _pools; /// @dev A mapping of all of the user stakes mapped first by pool and then by address. mapping(address => mapping(uint256 => Stake.Data)) private _stakes; constructor( IMintableERC20 _reward, address _governance ) public { require(_governance != address(0), "StakingPools: governance address cannot be 0x0"); reward = _reward; governance = _governance; } /// @dev A modifier which reverts when the caller is not the governance. modifier onlyGovernance() { require(msg.sender == governance, "StakingPools: only governance"); _; } /// @dev Sets the governance. /// /// This function can only called by the current governance. /// /// @param _pendingGovernance the new pending governance. function setPendingGovernance(address _pendingGovernance) external onlyGovernance { require(_pendingGovernance != address(0), "StakingPools: pending governance address cannot be 0x0"); pendingGovernance = _pendingGovernance; emit PendingGovernanceUpdated(_pendingGovernance); } function acceptGovernance() external { require(msg.sender == pendingGovernance, "StakingPools: only pending governance"); address _pendingGovernance = pendingGovernance; governance = _pendingGovernance; emit GovernanceUpdated(_pendingGovernance); } /// @dev Sets the distribution reward rate. /// /// This will update all of the pools. /// /// @param _rewardRate The number of tokens to distribute per second. function setRewardRate(uint256 _rewardRate) external onlyGovernance { _updatePools(); _ctx.rewardRate = _rewardRate; emit RewardRateUpdated(_rewardRate); } /// @dev Creates a new pool. /// /// The created pool will need to have its reward weight initialized before it begins generating rewards. /// /// @param _token The token the pool will accept for staking. /// /// @return the identifier for the newly created pool. function createPool(IERC20 _token) external onlyGovernance returns (uint256) { require(tokenPoolIds[_token] == 0, "StakingPools: token already has a pool"); uint256 _poolId = _pools.length(); _pools.push(Pool.Data({ token: _token, totalDeposited: 0, rewardWeight: 0, accumulatedRewardWeight: FixedPointMath.FixedDecimal(0), lastUpdatedBlock: block.number })); tokenPoolIds[_token] = _poolId + 1; emit PoolCreated(_poolId, _token); return _poolId; } /// @dev Sets the reward weights of all of the pools. /// /// @param _rewardWeights The reward weights of all of the pools. function setRewardWeights(uint256[] calldata _rewardWeights) external onlyGovernance { require(_rewardWeights.length == _pools.length(), "StakingPools: weights length mismatch"); _updatePools(); uint256 _totalRewardWeight = _ctx.totalRewardWeight; for (uint256 _poolId = 0; _poolId < _pools.length(); _poolId++) { Pool.Data storage _pool = _pools.get(_poolId); uint256 _currentRewardWeight = _pool.rewardWeight; if (_currentRewardWeight == _rewardWeights[_poolId]) { continue; } // FIXME _totalRewardWeight = _totalRewardWeight.sub(_currentRewardWeight).add(_rewardWeights[_poolId]); _pool.rewardWeight = _rewardWeights[_poolId]; emit PoolRewardWeightUpdated(_poolId, _rewardWeights[_poolId]); } _ctx.totalRewardWeight = _totalRewardWeight; } /// @dev Stakes tokens into a pool. /// /// @param _poolId the pool to deposit tokens into. /// @param _depositAmount the amount of tokens to deposit. function deposit(uint256 _poolId, uint256 _depositAmount) external nonReentrant { Pool.Data storage _pool = _pools.get(_poolId); _pool.update(_ctx); Stake.Data storage _stake = _stakes[msg.sender][_poolId]; _stake.update(_pool, _ctx); _deposit(_poolId, _depositAmount); } /// @dev Withdraws staked tokens from a pool. /// /// @param _poolId The pool to withdraw staked tokens from. /// @param _withdrawAmount The number of tokens to withdraw. function withdraw(uint256 _poolId, uint256 _withdrawAmount) external nonReentrant { Pool.Data storage _pool = _pools.get(_poolId); _pool.update(_ctx); Stake.Data storage _stake = _stakes[msg.sender][_poolId]; _stake.update(_pool, _ctx); _claim(_poolId); _withdraw(_poolId, _withdrawAmount); } /// @dev Claims all rewarded tokens from a pool. /// /// @param _poolId The pool to claim rewards from. /// /// @notice use this function to claim the tokens from a corresponding pool by ID. function claim(uint256 _poolId) external nonReentrant { Pool.Data storage _pool = _pools.get(_poolId); _pool.update(_ctx); Stake.Data storage _stake = _stakes[msg.sender][_poolId]; _stake.update(_pool, _ctx); _claim(_poolId); } /// @dev Claims all rewards from a pool and then withdraws all staked tokens. /// /// @param _poolId the pool to exit from. function exit(uint256 _poolId) external nonReentrant { Pool.Data storage _pool = _pools.get(_poolId); _pool.update(_ctx); Stake.Data storage _stake = _stakes[msg.sender][_poolId]; _stake.update(_pool, _ctx); _claim(_poolId); _withdraw(_poolId, _stake.totalDeposited); } /// @dev Gets the rate at which tokens are minted to stakers for all pools. /// /// @return the reward rate. function rewardRate() external view returns (uint256) { return _ctx.rewardRate; } /// @dev Gets the total reward weight between all the pools. /// /// @return the total reward weight. function totalRewardWeight() external view returns (uint256) { return _ctx.totalRewardWeight; } /// @dev Gets the number of pools that exist. /// /// @return the pool count. function poolCount() external view returns (uint256) { return _pools.length(); } /// @dev Gets the token a pool accepts. /// /// @param _poolId the identifier of the pool. /// /// @return the token. function getPoolToken(uint256 _poolId) external view returns (IERC20) { Pool.Data storage _pool = _pools.get(_poolId); return _pool.token; } /// @dev Gets the total amount of funds staked in a pool. /// /// @param _poolId the identifier of the pool. /// /// @return the total amount of staked or deposited tokens. function getPoolTotalDeposited(uint256 _poolId) external view returns (uint256) { Pool.Data storage _pool = _pools.get(_poolId); return _pool.totalDeposited; } /// @dev Gets the reward weight of a pool which determines how much of the total rewards it receives per block. /// /// @param _poolId the identifier of the pool. /// /// @return the pool reward weight. function getPoolRewardWeight(uint256 _poolId) external view returns (uint256) { Pool.Data storage _pool = _pools.get(_poolId); return _pool.rewardWeight; } /// @dev Gets the amount of tokens per block being distributed to stakers for a pool. /// /// @param _poolId the identifier of the pool. /// /// @return the pool reward rate. function getPoolRewardRate(uint256 _poolId) external view returns (uint256) { Pool.Data storage _pool = _pools.get(_poolId); return _pool.getRewardRate(_ctx); } /// @dev Gets the number of tokens a user has staked into a pool. /// /// @param _account The account to query. /// @param _poolId the identifier of the pool. /// /// @return the amount of deposited tokens. function getStakeTotalDeposited(address _account, uint256 _poolId) external view returns (uint256) { Stake.Data storage _stake = _stakes[_account][_poolId]; return _stake.totalDeposited; } /// @dev Gets the number of unclaimed reward tokens a user can claim from a pool. /// /// @param _account The account to get the unclaimed balance of. /// @param _poolId The pool to check for unclaimed rewards. /// /// @return the amount of unclaimed reward tokens a user has in a pool. function getStakeTotalUnclaimed(address _account, uint256 _poolId) external view returns (uint256) { Stake.Data storage _stake = _stakes[_account][_poolId]; return _stake.getUpdatedTotalUnclaimed(_pools.get(_poolId), _ctx); } /// @dev Updates all of the pools. function _updatePools() internal { for (uint256 _poolId = 0; _poolId < _pools.length(); _poolId++) { Pool.Data storage _pool = _pools.get(_poolId); _pool.update(_ctx); } } /// @dev Stakes tokens into a pool. /// /// The pool and stake MUST be updated before calling this function. /// /// @param _poolId the pool to deposit tokens into. /// @param _depositAmount the amount of tokens to deposit. function _deposit(uint256 _poolId, uint256 _depositAmount) internal { Pool.Data storage _pool = _pools.get(_poolId); Stake.Data storage _stake = _stakes[msg.sender][_poolId]; _pool.totalDeposited = _pool.totalDeposited.add(_depositAmount); _stake.totalDeposited = _stake.totalDeposited.add(_depositAmount); _pool.token.safeTransferFrom(msg.sender, address(this), _depositAmount); emit TokensDeposited(msg.sender, _poolId, _depositAmount); } /// @dev Withdraws staked tokens from a pool. /// /// The pool and stake MUST be updated before calling this function. /// /// @param _poolId The pool to withdraw staked tokens from. /// @param _withdrawAmount The number of tokens to withdraw. function _withdraw(uint256 _poolId, uint256 _withdrawAmount) internal { Pool.Data storage _pool = _pools.get(_poolId); Stake.Data storage _stake = _stakes[msg.sender][_poolId]; _pool.totalDeposited = _pool.totalDeposited.sub(_withdrawAmount); _stake.totalDeposited = _stake.totalDeposited.sub(_withdrawAmount); _pool.token.safeTransfer(msg.sender, _withdrawAmount); emit TokensWithdrawn(msg.sender, _poolId, _withdrawAmount); } /// @dev Claims all rewarded tokens from a pool. /// /// The pool and stake MUST be updated before calling this function. /// /// @param _poolId The pool to claim rewards from. /// /// @notice use this function to claim the tokens from a corresponding pool by ID. function _claim(uint256 _poolId) internal { Stake.Data storage _stake = _stakes[msg.sender][_poolId]; uint256 _claimAmount = _stake.totalUnclaimed; _stake.totalUnclaimed = 0; reward.mint(msg.sender, _claimAmount); emit TokensClaimed(msg.sender, _poolId, _claimAmount); } } // 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: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../FixedPointMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; import "hardhat/console.sol"; /// @title Pool /// /// @dev A library which provides the Pool data struct and associated functions. library Pool { using FixedPointMath for FixedPointMath.FixedDecimal; using Pool for Pool.Data; using Pool for Pool.List; using SafeMath for uint256; struct Context { uint256 rewardRate; uint256 totalRewardWeight; } struct Data { IERC20 token; uint256 totalDeposited; uint256 rewardWeight; FixedPointMath.FixedDecimal accumulatedRewardWeight; uint256 lastUpdatedBlock; } struct List { Data[] elements; } /// @dev Updates the pool. /// /// @param _ctx the pool context. function update(Data storage _data, Context storage _ctx) internal { _data.accumulatedRewardWeight = _data.getUpdatedAccumulatedRewardWeight(_ctx); _data.lastUpdatedBlock = block.number; } /// @dev Gets the rate at which the pool will distribute rewards to stakers. /// /// @param _ctx the pool context. /// /// @return the reward rate of the pool in tokens per block. function getRewardRate(Data storage _data, Context storage _ctx) internal view returns (uint256) { // console.log("get reward rate"); // console.log(uint(_data.rewardWeight)); // console.log(uint(_ctx.totalRewardWeight)); // console.log(uint(_ctx.rewardRate)); return _ctx.rewardRate.mul(_data.rewardWeight).div(_ctx.totalRewardWeight); } /// @dev Gets the accumulated reward weight of a pool. /// /// @param _ctx the pool context. /// /// @return the accumulated reward weight. function getUpdatedAccumulatedRewardWeight(Data storage _data, Context storage _ctx) internal view returns (FixedPointMath.FixedDecimal memory) { if (_data.totalDeposited == 0) { return _data.accumulatedRewardWeight; } uint256 _elapsedTime = block.number.sub(_data.lastUpdatedBlock); if (_elapsedTime == 0) { return _data.accumulatedRewardWeight; } uint256 _rewardRate = _data.getRewardRate(_ctx); uint256 _distributeAmount = _rewardRate.mul(_elapsedTime); if (_distributeAmount == 0) { return _data.accumulatedRewardWeight; } FixedPointMath.FixedDecimal memory _rewardWeight = FixedPointMath.fromU256(_distributeAmount).div(_data.totalDeposited); return _data.accumulatedRewardWeight.add(_rewardWeight); } /// @dev Adds an element to the list. /// /// @param _element the element to add. function push(List storage _self, Data memory _element) internal { _self.elements.push(_element); } /// @dev Gets an element from the list. /// /// @param _index the index in the list. /// /// @return the element at the specified index. function get(List storage _self, uint256 _index) internal view returns (Data storage) { return _self.elements[_index]; } /// @dev Gets the last element in the list. /// /// This function will revert if there are no elements in the list. ///ck /// @return the last element in the list. function last(List storage _self) internal view returns (Data storage) { return _self.elements[_self.lastIndex()]; } /// @dev Gets the index of the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the index of the last element. function lastIndex(List storage _self) internal view returns (uint256) { uint256 _length = _self.length(); return _length.sub(1, "Pool.List: list is empty"); } /// @dev Gets the number of elements in the list. /// /// @return the number of elements. function length(List storage _self) internal view returns (uint256) { return _self.elements.length; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../FixedPointMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; import {Pool} from "./Pool.sol"; import "hardhat/console.sol"; /// @title Stake /// /// @dev A library which provides the Stake data struct and associated functions. library Stake { using FixedPointMath for FixedPointMath.FixedDecimal; using Pool for Pool.Data; using SafeMath for uint256; using Stake for Stake.Data; struct Data { uint256 totalDeposited; uint256 totalUnclaimed; FixedPointMath.FixedDecimal lastAccumulatedWeight; } function update(Data storage _self, Pool.Data storage _pool, Pool.Context storage _ctx) internal { _self.totalUnclaimed = _self.getUpdatedTotalUnclaimed(_pool, _ctx); _self.lastAccumulatedWeight = _pool.getUpdatedAccumulatedRewardWeight(_ctx); } function getUpdatedTotalUnclaimed(Data storage _self, Pool.Data storage _pool, Pool.Context storage _ctx) internal view returns (uint256) { FixedPointMath.FixedDecimal memory _currentAccumulatedWeight = _pool.getUpdatedAccumulatedRewardWeight(_ctx); FixedPointMath.FixedDecimal memory _lastAccumulatedWeight = _self.lastAccumulatedWeight; if (_currentAccumulatedWeight.cmp(_lastAccumulatedWeight) == 0) { return _self.totalUnclaimed; } uint256 _distributedAmount = _currentAccumulatedWeight .sub(_lastAccumulatedWeight) .mul(_self.totalDeposited) .decode(); return _self.totalUnclaimed.add(_distributedAmount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IDetailedERC20} from "./interfaces/IDetailedERC20.sol"; /// @title TimeToken /// /// @dev This is the contract for the Alchemix time token. /// contract TimeToken is AccessControl, ERC20("Technological Instantiation Meta Env", "TIME") { /// @dev The identifier of the role which maintains other roles. bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); /// @dev The identifier of the role which allows accounts to mint tokens. bytes32 public constant MINTER_ROLE = keccak256("MINTER"); constructor() public { _setupRole(ADMIN_ROLE, msg.sender); _setupRole(MINTER_ROLE, msg.sender); _setRoleAdmin(MINTER_ROLE, ADMIN_ROLE); _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE); } /// @dev A modifier which checks that the caller has the minter role. modifier onlyMinter() { require(hasRole(MINTER_ROLE, msg.sender), "TimeToken: only minter"); _; } /// @dev Mints tokens to a recipient. /// /// This function reverts if the caller does not have the minter role. /// /// @param _recipient the account to mint tokens to. /// @param _amount the amount of tokens to mint. function mint(address _recipient, uint256 _amount) external onlyMinter { _mint(_recipient, _amount); } } // 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"; 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 {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // 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)); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IDetailedERC20} from "./interfaces/IDetailedERC20.sol"; /// @title AlToken /// /// @dev This is the contract for the Alchemix utillity token usd. /// /// Initially, the contract deployer is given both the admin and minter role. This allows them to pre-mine tokens, /// transfer admin to a timelock contract, and lastly, grant the staking pools the minter role. After this is done, /// the deployer must revoke their admin role and minter role. contract AlToken is AccessControl, ERC20("Alchemix USD", "alUSD") { using SafeERC20 for ERC20; /// @dev The identifier of the role which maintains other roles. bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); /// @dev The identifier of the role which allows accounts to mint tokens. bytes32 public constant SENTINEL_ROLE = keccak256("SENTINEL"); /// @dev addresses whitelisted for minting new tokens mapping (address => bool) public whiteList; /// @dev addresses blacklisted for minting new tokens mapping (address => bool) public blacklist; /// @dev addresses paused for minting new tokens mapping (address => bool) public paused; /// @dev ceiling per address for minting new tokens mapping (address => uint256) public ceiling; /// @dev already minted amount per address to track the ceiling mapping (address => uint256) public hasMinted; event Paused(address alchemistAddress, bool isPaused); constructor() public { _setupRole(ADMIN_ROLE, msg.sender); _setupRole(SENTINEL_ROLE, msg.sender); _setRoleAdmin(SENTINEL_ROLE,ADMIN_ROLE); _setRoleAdmin(ADMIN_ROLE,ADMIN_ROLE); } /// @dev A modifier which checks if whitelisted for minting. modifier onlyWhitelisted() { require(whiteList[msg.sender], "AlUSD: Alchemist is not whitelisted"); _; } /// @dev Mints tokens to a recipient. /// /// This function reverts if the caller does not have the minter role. /// /// @param _recipient the account to mint tokens to. /// @param _amount the amount of tokens to mint. function mint(address _recipient, uint256 _amount) external onlyWhitelisted { require(!blacklist[msg.sender], "AlUSD: Alchemist is blacklisted."); uint256 _total = _amount.add(hasMinted[msg.sender]); require(_total <= ceiling[msg.sender],"AlUSD: Alchemist's ceiling was breached."); require(!paused[msg.sender], "AlUSD: user is currently paused."); hasMinted[msg.sender] = hasMinted[msg.sender].add(_amount); _mint(_recipient, _amount); } /// This function reverts if the caller does not have the admin role. /// /// @param _toWhitelist the account to mint tokens to. /// @param _state the whitelist state. function setWhitelist(address _toWhitelist, bool _state) external onlyAdmin { whiteList[_toWhitelist] = _state; } /// This function reverts if the caller does not have the admin role. /// /// @param _newSentinel the account to set as sentinel. function setSentinel(address _newSentinel) external onlyAdmin { _setupRole(SENTINEL_ROLE, _newSentinel); } /// This function reverts if the caller does not have the admin role. /// /// @param _toBlacklist the account to mint tokens to. function setBlacklist(address _toBlacklist) external onlySentinel { blacklist[_toBlacklist] = true; } /// This function reverts if the caller does not have the admin role. function pauseAlchemist(address _toPause, bool _state) external onlySentinel { paused[_toPause] = _state; Paused(_toPause, _state); } /// This function reverts if the caller does not have the admin role. /// /// @param _toSetCeiling the account set the ceiling off. /// @param _ceiling the max amount of tokens the account is allowed to mint. function setCeiling(address _toSetCeiling, uint256 _ceiling) external onlyAdmin { ceiling[_toSetCeiling] = _ceiling; } /// @dev A modifier which checks that the caller has the admin role. modifier onlyAdmin() { require(hasRole(ADMIN_ROLE, msg.sender), "only admin"); _; } /// @dev A modifier which checks that the caller has the sentinel role. modifier onlySentinel() { require(hasRole(SENTINEL_ROLE, msg.sender), "only sentinel"); _; } /** * @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 lowers hasminted from the caller's allocation * */ function lowerHasMinted( uint256 amount) public onlyWhitelisted { hasMinted[msg.sender] = hasMinted[msg.sender].sub(amount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "hardhat/console.sol"; 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/IYearnController.sol"; import "../interfaces/IYearnVault.sol"; contract YearnVaultMock is ERC20 { using SafeERC20 for IDetailedERC20; using SafeMath for uint256; uint256 public min = 9500; uint256 public constant max = 10000; IYearnController public controller; IDetailedERC20 public token; constructor(IDetailedERC20 _token, IYearnController _controller) public ERC20("yEarn Mock", "yMOCK") { token = _token; controller = _controller; } function vdecimals() external view returns (uint8) { return decimals(); } function balance() public view returns (uint256) { return token.balanceOf(address(this)).add(controller.balanceOf(address(token))); } function available() public view returns (uint256) { return token.balanceOf(address(this)).mul(min).div(max); } function earn() external { uint _bal = available(); token.safeTransfer(address(controller), _bal); controller.earn(address(token), _bal); } function deposit(uint256 _amount) external returns (uint){ uint _pool = balance(); uint _before = token.balanceOf(address(this)); token.safeTransferFrom(msg.sender, address(this), _amount); uint _after = token.balanceOf(address(this)); _amount = _after.sub(_before); // Additional check for deflationary tokens uint _shares = 0; if (totalSupply() == 0) { _shares = _amount; } else { _shares = (_amount.mul(totalSupply())).div(_pool); } _mint(msg.sender, _shares); } function withdraw(uint _shares, address _recipient) external returns (uint) { uint _r = (balance().mul(_shares)).div(totalSupply()); _burn(msg.sender, _shares); // Check balance uint _b = token.balanceOf(address(this)); if (_b < _r) { uint _withdraw = _r.sub(_b); controller.withdraw(address(token), _withdraw); uint _after = token.balanceOf(address(this)); uint _diff = _after.sub(_b); if (_diff < _withdraw) { _r = _b.add(_diff); } } token.safeTransfer(_recipient, _r); } function pricePerShare() external view returns (uint256) { return balance().mul(1e18).div(totalSupply()); }// changed to v2 /// @dev This is not part of the vault contract and is meant for quick debugging contracts to have control over /// completely clearing the vault buffer to test certain behaviors better. function clear() external { token.safeTransfer(address(controller), token.balanceOf(address(this))); controller.earn(address(token), token.balanceOf(address(this))); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; interface IYearnController { function balanceOf(address _token) external view returns (uint256); function earn(address _token, uint256 _amount) external; function withdraw(address _token, uint256 _withdrawAmount) external; } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IDetailedERC20} from "./IDetailedERC20.sol"; interface IYearnVault { function balanceOf(address user) external view returns (uint); function pricePerShare() external view returns (uint); function deposit(uint amount) external returns (uint); function withdraw(uint shares, address recipient) external returns (uint); function token() external view returns (IDetailedERC20); function totalAssets() external view returns (uint); function decimals() external view returns (uint8); } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "hardhat/console.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import "../interfaces/IYearnController.sol"; contract YearnControllerMock is IYearnController { using SafeERC20 for IERC20; using SafeMath for uint256; address constant public blackhole = 0x000000000000000000000000000000000000dEaD; uint256 public withdrawalFee = 50; uint256 constant public withdrawalMax = 10000; function setWithdrawalFee(uint256 _withdrawalFee) external { withdrawalFee = _withdrawalFee; } function balanceOf(address _token) external view override returns (uint256) { return IERC20(_token).balanceOf(address(this)); } function earn(address _token, uint256 _amount) external override { } function withdraw(address _token, uint256 _amount) external override { uint _balance = IERC20(_token).balanceOf(address(this)); // uint _fee = _amount.mul(withdrawalFee).div(withdrawalMax); // IERC20(_token).safeTransfer(blackhole, _fee); IERC20(_token).safeTransfer(msg.sender, _amount); } } /* 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.6.12; import "@openzeppelin/contracts/math/SafeMath.sol"; import "./MultiSigWallet.sol"; /// @title Multisignature wallet with time lock- Allows multiple parties to execute a transaction after a time lock has passed. /// @author Amir Bandeali - <[email protected]> // solhint-disable not-rely-on-time contract MultiSigWalletWithTimeLock is MultiSigWallet { using SafeMath for uint256; event ConfirmationTimeSet(uint256 indexed transactionId, uint256 confirmationTime); event TimeLockChange(uint256 secondsTimeLocked); uint256 public secondsTimeLocked; mapping (uint256 => uint256) public confirmationTimes; modifier fullyConfirmed(uint256 transactionId) { require( isConfirmed(transactionId), "TX_NOT_FULLY_CONFIRMED" ); _; } modifier pastTimeLock(uint256 transactionId) { require( block.timestamp >= confirmationTimes[transactionId].add(secondsTimeLocked), "TIME_LOCK_INCOMPLETE" ); _; } /// @dev Contract constructor sets initial owners, required number of confirmations, and time lock. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. constructor ( address[] memory _owners, uint256 _required, uint256 _secondsTimeLocked ) public MultiSigWallet(_owners, _required) { secondsTimeLocked = _secondsTimeLocked; } /// @dev Changes the duration of the time lock for transactions. /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds. function changeTimeLock(uint256 _secondsTimeLocked) public onlyWallet { secondsTimeLocked = _secondsTimeLocked; emit TimeLockChange(_secondsTimeLocked); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint256 transactionId) public override ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { bool isTxFullyConfirmedBeforeConfirmation = isConfirmed(transactionId); confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); if (!isTxFullyConfirmedBeforeConfirmation && isConfirmed(transactionId)) { _setConfirmationTime(transactionId, block.timestamp); } } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint256 transactionId) public override notExecuted(transactionId) fullyConfirmed(transactionId) pastTimeLock(transactionId) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) { emit Execution(transactionId); } else { emit ExecutionFailure(transactionId); txn.executed = false; } } /// @dev Sets the time of when a submission first passed. function _setConfirmationTime(uint256 transactionId, uint256 confirmationTime) internal { confirmationTimes[transactionId] = confirmationTime; emit ConfirmationTimeSet(transactionId, confirmationTime); } } pragma solidity ^0.6.12; /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - <[email protected]> contract MultiSigWallet { /* * Events */ event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event RequirementChange(uint required); /* * Constants */ uint constant public MAX_OWNER_COUNT = 50; /* * Storage */ mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; struct Transaction { address destination; uint value; bytes data; bool executed; } /* * Modifiers */ modifier onlyWallet() { require(msg.sender == address(this)); _; } modifier ownerDoesNotExist(address owner) { require(!isOwner[owner]); _; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != address(0)); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != address(0)); _; } modifier validRequirement(uint ownerCount, uint _required) { require(ownerCount <= MAX_OWNER_COUNT && _required <= ownerCount && _required != 0 && ownerCount != 0); _; } /// @dev Fallback function allows to deposit ether. fallback() external payable { if (msg.value > 0) emit Deposit(msg.sender, msg.value); } /* * Public functions */ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor(address[] memory _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != address(0)); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.pop(); if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param newOwner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId Returns transaction ID. function submitTransaction(address destination, uint value, bytes memory data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public virtual ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public virtual ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) Execution(transactionId); else { ExecutionFailure(transactionId); txn.executed = false; } } } // call has been separated into its own function in order to take advantage // of the Solidity's code generator to produce a loop that copies tx.data into memory. function external_call(address destination, uint value, uint dataLength, bytes memory data) internal returns (bool) { bool result; assembly { let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention) let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that result := call( sub(gas(), 34710), // 34710 is the value that solidity is currently emitting // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) + // callNewAccountGas (25000, in case the destination address does not exist and needs creating) destination, value, d, dataLength, // Size of the input (in bytes) - this is what fixes the padding problem x, 0 // Output is ignored, therefore the output size is zero ) } return result; } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public view returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /* * Internal functions */ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return transactionId Returns transaction ID. function addTransaction(address destination, uint value, bytes memory data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return count Number of confirmations. function getConfirmationCount(uint transactionId) public view returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return count Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public view returns (uint count) { for (uint i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public view returns (address[] memory) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return _confirmations Returns array of owner addresses. function getConfirmations(uint transactionId) public view returns (address[] memory _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return _transactionIds Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public view returns (uint[] memory _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if ( pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../FixedPointMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; import {Round} from "./Round.sol"; /// @title Stake /// /// @dev A library which provides the Stake data struct and associated functions. library Stake { using FixedPointMath for FixedPointMath.FixedDecimal; using Round for Round.Data; using SafeMath for uint256; using Stake for Stake.Data; struct Data { uint256 totalDeposited; uint256 totalWeightedTime; uint256 lastUpdateTime; bool claimed; } function update(Data storage _self) internal { _self.totalWeightedTime = _self.getUpdatedTotalWeightedTime(); _self.lastUpdateTime = block.timestamp; } function getExchangedBalance(Data storage _self, Round.Data storage _round) internal view returns (uint256) { FixedPointMath.FixedDecimal memory _distributeWeight = _round.getDistributeWeight(); FixedPointMath.FixedDecimal memory _exchangedBalance = _distributeWeight.mul(_self.totalDeposited); return _exchangedBalance.decode(); } function getUnexchangedBalance(Data storage _self, Round.Data storage _round) internal view returns (uint256) { return _self.totalDeposited.sub(_self.getExchangedBalance(_round)); } function getRemainingLockupTime(Data storage _self, Round.Data storage _round) internal view returns (uint256) { uint256 _requiredWeightedTime = _self.getRequiredTotalWeightedTime(_round); uint256 _totalWeightedTime = _self.getUpdatedTotalWeightedTime(); if (_totalWeightedTime >= _requiredWeightedTime) { return 0; } uint256 _difference = _requiredWeightedTime.sub(_totalWeightedTime); uint256 _totalDeposited = _self.totalDeposited; if (_totalDeposited == 0) { return 0; } return _difference.div(_totalDeposited); } function getRequiredTotalWeightedTime(Data storage _self, Round.Data storage _round) internal view returns (uint256) { return _self.totalDeposited.mul(_round.lockupDuration); } function getUpdatedTotalWeightedTime(Data storage _self) internal view returns (uint256) { uint256 _elapsedTime = block.timestamp.sub(_self.lastUpdateTime); if (_elapsedTime == 0) { return _self.totalWeightedTime; } uint256 _weightedTime = _self.totalDeposited.mul(_elapsedTime); return _self.totalWeightedTime.add(_weightedTime); } function isUnlocked(Data storage _self, Round.Data storage _round) internal view returns (bool) { uint256 _requiredWeightedTime = _self.getRequiredTotalWeightedTime(_round); uint256 _totalWeightedTime = _self.getUpdatedTotalWeightedTime(); return _totalWeightedTime >= _requiredWeightedTime; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../FixedPointMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; library Round { using FixedPointMath for FixedPointMath.FixedDecimal; using Round for Data; using Round for List; using SafeMath for uint256; struct Data { uint256 availableBalance; uint256 commitEndTime; uint256 lockupDuration; uint256 totalDeposited; } struct List { Data[] elements; } /// @dev Gets if the round has been completed. /// /// @return if the current time is equal to or after the round's end time. function isCommitPhaseComplete(Data storage _self) internal view returns (bool) { return block.timestamp >= _self.commitEndTime; } /// @dev Gets the current amount of tokens to distribute per token staked. /// /// @return the distribute weight. function getDistributeWeight(Data storage _self) internal view returns (FixedPointMath.FixedDecimal memory) { FixedPointMath.FixedDecimal memory _weight = FixedPointMath.fromU256(_self.getDistributeBalance()); return _weight.div(_self.totalDeposited); } /// @dev Gets the amount to distribute to stakers. /// /// @return the amount to distribute. function getDistributeBalance(Data storage _self) internal view returns (uint256) { return Math.min(_self.availableBalance, _self.totalDeposited); } /// @dev Gets the amount to distribute in the next round. /// /// @return the runoff amount. function getRunoffBalance(Data storage _self) internal view returns (uint256) { return _self.availableBalance.sub(_self.getDistributeBalance()); } /// @dev Adds a round to the list. /// /// @param _element the element to add. function push(List storage _self, Data memory _element) internal { _self.elements.push(_element); } /// @dev Gets a element from the list. /// /// @param _index the index in the list. /// /// @return the element at the specified index. function get(List storage _self, uint256 _index) internal view returns (Data storage) { return _self.elements[_index]; } /// @dev Gets the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the last element in the list. function last(List storage _self) internal view returns (Data storage) { return _self.elements[_self.lastIndex()]; } /// @dev Gets the index of the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the index of the last element. function lastIndex(List storage _self) internal view returns (uint256) { uint256 _length = _self.length(); return _length.sub(1, "Round.List: list is empty"); } /// @dev Gets the number of elements in the list. /// /// @return the number of elements. function length(List storage _self) internal view returns (uint256) { return _self.elements.length; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Math} from "@openzeppelin/contracts/math/Math.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {FixedPointMath} from "../FixedPointMath.sol"; import {IDetailedERC20} from "../../interfaces/IDetailedERC20.sol"; library Vault { using FixedPointMath for FixedPointMath.FixedDecimal; using Vault for Data; using Vault for List; using SafeMath for uint256; struct Data { IERC20 token; address owner; uint256 lockedAmount; uint256 totalClaimed; uint256 startTime; uint256 endTime; } struct List { Data[] elements; } /// @dev Gets the duration of the vesting period. /// /// @return the duration of the vesting period in seconds. function getDuration(Data storage _self) internal view returns (uint256) { return _self.endTime.sub(_self.startTime); } /// @dev Gets the amount of tokens that have been released up to the current moment. /// /// @return the released amount of tokens. function getReleasedAmount(Data storage _self) internal view returns (uint256) { if (block.timestamp < _self.startTime) { return 0; } uint256 _lowerTime = block.timestamp; uint256 _upperTime = Math.min(block.timestamp, _self.endTime); uint256 _elapsedTime = _upperTime.sub(_lowerTime); uint256 _numerator = _self.lockedAmount.mul(_elapsedTime); uint256 _denominator = _self.getDuration(); return _numerator.div(_denominator); } /// @dev Gets the amount of tokens that are available to be claimed from a vault. /// /// @return the available amount of tokens. function getAvailableAmount(Data storage _self) internal view returns (uint256) { uint256 _releasedAmount = _self.getReleasedAmount(); return _releasedAmount.sub(_self.totalClaimed); } /// @dev Adds a round to the list. /// /// @param _element the element to add. function push(List storage _self, Data memory _element) internal { _self.elements.push(_element); } /// @dev Gets a element from the list. /// /// @param _index the index in the list. /// /// @return the element at the specified index. function get(List storage _self, uint256 _index) internal view returns (Data storage) { return _self.elements[_index]; } /// @dev Gets the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the last element in the list. function last(List storage _self) internal view returns (Data storage) { return _self.elements[_self.lastIndex()]; } /// @dev Gets the index of the last element in the list. /// /// This function will revert if there are no elements in the list. /// /// @return the index of the last element. function lastIndex(List storage _self) internal view returns (uint256) { uint256 _length = _self.length(); return _length.sub(1, "Vault.List: list is empty"); } /// @dev Gets the number of elements in the list. /// /// @return the number of elements. function length(List storage _self) internal view returns (uint256) { return _self.elements.length; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../interfaces/IVaultAdapter.sol"; contract VaultAdapterMockWithIndirection is IVaultAdapter { using SafeERC20 for IDetailedERC20; IDetailedERC20 private _token; constructor(IDetailedERC20 token_) public { _token = token_; } function token() external view override returns (IDetailedERC20) { return _token; } function totalValue() external view override returns (uint256) { return _token.balanceOf(address(this)); } function deposit(uint256 _amount) external override { } function withdraw(address _recipient, uint256 _amount) external override { _token.safeTransfer(_recipient, _amount); } function indirectWithdraw(address _recipient, uint256 _amount) external { _token.safeTransfer(_recipient, _amount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../interfaces/IVaultAdapter.sol"; contract VaultAdapterMock is IVaultAdapter { using SafeERC20 for IDetailedERC20; IDetailedERC20 private _token; constructor(IDetailedERC20 token_) public { _token = token_; } function token() external view override returns (IDetailedERC20) { return _token; } function totalValue() external view override returns (uint256) { return _token.balanceOf(address(this)); } function deposit(uint256 _amount) external override { _amount; } function withdraw(address _recipient, uint256 _amount) external override { _token.safeTransfer(_recipient, _amount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; /// @title ERC20Mock /// /// @dev A mock of an ERC20 token which lets anyone burn and mint tokens. contract ERC20Mock is ERC20 { constructor(string memory _name, string memory _symbol, uint8 _decimals) public ERC20(_name, _symbol) { _setupDecimals(_decimals); } function mint(address _recipient, uint256 _amount) external { _mint(_recipient, _amount); } function burn(address _account, uint256 _amount) external { _burn(_account, _amount); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IDetailedERC20} from "./interfaces/IDetailedERC20.sol"; /// @title AlchemixToken /// /// @dev This is the contract for the Alchemix governance token. /// /// Initially, the contract deployer is given both the admin and minter role. This allows them to pre-mine tokens, /// transfer admin to a timelock contract, and lastly, grant the staking pools the minter role. After this is done, /// the deployer must revoke their admin role and minter role. contract AlchemixToken is AccessControl, ERC20("Alchemix", "ALCX") { /// @dev The identifier of the role which maintains other roles. bytes32 public constant ADMIN_ROLE = keccak256("ADMIN"); /// @dev The identifier of the role which allows accounts to mint tokens. bytes32 public constant MINTER_ROLE = keccak256("MINTER"); constructor() public { _setupRole(ADMIN_ROLE, msg.sender); _setupRole(MINTER_ROLE, msg.sender); _setRoleAdmin(MINTER_ROLE, ADMIN_ROLE); _setRoleAdmin(ADMIN_ROLE, ADMIN_ROLE); } /// @dev A modifier which checks that the caller has the minter role. modifier onlyMinter() { require(hasRole(MINTER_ROLE, msg.sender), "AlchemixToken: only minter"); _; } /// @dev Mints tokens to a recipient. /// /// This function reverts if the caller does not have the minter role. /// /// @param _recipient the account to mint tokens to. /// @param _amount the amount of tokens to mint. function mint(address _recipient, uint256 _amount) external onlyMinter { _mint(_recipient, _amount); } }
0x608060405234801561001057600080fd5b506004361061034c5760003560e01c806379070a12116101bd578063bff170b9116100f9578063edaafe20116100a2578063f58c251c1161007c578063f58c251c1461096f578063f93f394c14610977578063fb932108146109aa578063fc0c546a146109e35761034c565b8063edaafe2014610957578063f1f792001461095f578063f39c38a0146109675761034c565b8063e044205e116100d3578063e044205e14610914578063e9fad8ee1461091c578063ec38a862146109245761034c565b8063bff170b91461088e578063d2c29492146108c1578063ddc63262146108de5761034c565b80639f4216e811610166578063a694fc3a11610140578063a694fc3a146107ec578063b870d59814610809578063bedb86fb1461083c578063bf51929f1461085b5761034c565b80639f4216e8146107aa578063a02fbe2d146107c7578063a196cf2e146107e45761034c565b80638456cb59116101975780638456cb591461077d57806394ff1199146107855780639ec5a894146107a25761034c565b806379070a12146106e4578063806985f7146107175780638391e45c1461074a5761034c565b80632e17de781161028c578063538ba4f911610235578063658b98a91161020f578063658b98a91461067e5780636790fab31461068657806370460eb11461068e57806375b7f650146106b15761034c565b8063538ba4f91461060a57806353d6fd591461063b5780635aa6e675146106765761034c565b80634bf04bd1116102665780634bf04bd1146105c75780634e71d92d146105cf57806352710007146105d75761034c565b80632e17de781461055b578063372c12b1146105785780633cb802b9146105bf5761034c565b80631959a002116102f95780632113342d116102d35780632113342d1461053b578063238efcbc146105435780632a03cf681461054b5780632a3d7c81146105535761034c565b80631959a002146104d25780631acce0301461052b5780631aeb1986146105335761034c565b80630668911e1161032a5780630668911e1461044d57806309dac0611461046c5780630abb60351461049f5761034c565b806301f50c8614610351578063030362901461036b57806305d2301d14610427575b600080fd5b6103596109eb565b60408051918252519081900360200190f35b61038e6004803603604081101561038157600080fd5b50803590602001356109f1565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156103d25781810151838201526020016103ba565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156104115781810151838201526020016103f9565b5050505090500194505050505060405180910390f35b61042f610c4e565b60408051938452602084019290925282820152519081900360600190f35b61046a6004803603602081101561046357600080fd5b5035610c88565b005b61046a6004803603602081101561048257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610d49565b61046a600480360360208110156104b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610eb4565b610505600480360360208110156104e857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611035565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61035961114e565b610359611154565b61035961115a565b61046a611160565b61046a611262565b610359611274565b61046a6004803603602081101561057157600080fd5b503561127a565b6105ab6004803603602081101561058e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661146a565b604080519115158252519081900360200190f35b61035961147f565b610359611485565b61046a61148b565b610359600480360360208110156105ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611559565b61061261156b565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61046a6004803603604081101561065157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001351515611570565b610612611685565b6103596116a1565b6106126116a7565b61046a600480360360408110156106a457600080fd5b50803590602001356116c3565b61046a600480360360208110156106c757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611788565b6105ab600480360360208110156106fa57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166119f9565b6103596004803603602081101561072d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611a0e565b6103596004803603602081101561076057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611a20565b6105ab611a96565b61046a6004803603602081101561079b57600080fd5b5035611ab7565b610612611b78565b610612600480360360208110156107c057600080fd5b5035611b94565b61046a600480360360208110156107dd57600080fd5b5035611bbc565b610359611c7d565b61046a6004803603602081101561080257600080fd5b5035611c83565b6103596004803603602081101561081f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611f92565b61046a6004803603602081101561085257600080fd5b50351515611fa4565b61046a6004803603602081101561087157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166120cb565b61046a600480360360208110156108a457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661249e565b61046a600480360360208110156108d757600080fd5b50356129c8565b6108fb600480360360208110156108f457600080fd5b5035612a8b565b6040805192835260208301919091528051918290030190f35b61046a612b10565b61046a612b39565b61046a6004803603602081101561093a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612b41565b610359612cac565b61046a612cb2565b610612613069565b610612613085565b6103596004803603602081101561098d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166130a1565b61046a600480360360408110156109c057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356130b3565b6106126132cb565b60005481565b60608083808403828167ffffffffffffffff81118015610a1057600080fd5b50604051908082528060200260200182016040528015610a3a578160200160208202803683370190505b50905060608260020267ffffffffffffffff81118015610a5957600080fd5b50604051908082528060200260200182016040528015610a83578160200160208202803683370190505b509050600080610ab6600054610ab0610aa7600c54436132e790919063ffffffff16565b600b5490613332565b906133a5565b9050600054610ad0600c54436132e790919063ffffffff16565b1115610adb5750600b545b60005b85811015610c3b57600087815260086020526040902054855173ffffffffffffffffffffffffffffffffffffffff90911690869083908110610b1c57fe5b73ffffffffffffffffffffffffffffffffffffffff9283166020918202929092018101919091526000898152600882526040808220549093168152600390915220548451859085908110610b6c57fe5b602090810291909101810191909152600a5460008981526008835260408082205473ffffffffffffffffffffffffffffffffffffffff16825260039093529190912054610c0e91610bc291610ab0908690613332565b60008981526008602081815260408084205473ffffffffffffffffffffffffffffffffffffffff168085526004835290842054938d9052919052610c0891908290611a20565b906133e7565b848460010181518110610c1d57fe5b60209081029190910101526001968701966002939093019201610ade565b50929650909450505050505b9250929050565b6000806000610c68600c54436132e790919063ffffffff16565b600b546000549193509150610c8190610ab08385613332565b9250909192565b60135473ffffffffffffffffffffffffffffffffffffffff163314610d0e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b60118190556040805182815290517fe77487d7758cc0f4820329f0d13f96448757377d4bf03ca31ce49cc9e151486f9181900360200190a150565b60135473ffffffffffffffffffffffffffffffffffffffff163314610dcf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610e3b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614532602b913960400191505060405180910390fd5b6015805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517fdc117600f93282860144d2cd2745f8e2e15c3ca2a32b4290c30f7cd1ae7ffcb99181900360200190a150565b60135473ffffffffffffffffffffffffffffffffffffffff163314610f3a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610fbc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f5472616e736d757465723a203020676f76000000000000000000000000000000604482015290519081900360640190fd5b6014805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517fc9e2377236eab4280090ce8f2317332649736d92f00dcf20a8dd6684ec5e78399181900360200190a150565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600360205260408120548154600c54839283928392839161107b91610ab090610aa79043906132e7565b9050600054611095600c54436132e790919063ffffffff16565b11156110a05750600b545b600a5473ffffffffffffffffffffffffffffffffffffffff881660009081526003602052604081205490916110da91610ab0908590613332565b905060006111166110ea8a611a20565b73ffffffffffffffffffffffffffffffffffffffff8b16600090815260046020526040902054906133e7565b73ffffffffffffffffffffffffffffffffffffffff999099166000908152600560205260409020549399919897509295509350505050565b60125481565b60115481565b600e5481565b60145473ffffffffffffffffffffffffffffffffffffffff1633146111e657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f2170656e64696e67476f7665726e616e63650000000000000000000000000000604482015290519081900360640190fd5b601454601380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90921691821790556040805182815290517f9d3e522e1e47a2f6009739342b9cc7b252a1888154e843ab55ee1c81745795ab9181900360200190a150565b61126a612cb2565b61127261148b565b565b600c5481565b33600061128682611a20565b905080156112f557600f5461129b90826132e7565b600f5573ffffffffffffffffffffffffffffffffffffffff82166000908152600460205260409020546112ce90826133e7565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600460205260409020555b600e5473ffffffffffffffffffffffffffffffffffffffff831660009081526006602090815260408083209390935533808352600390915291902054841115611389576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806144856033913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81166000908152600360205260409020546113b990856132e7565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260036020526040902055600a546113ec90856132e7565b600a556001546114139073ffffffffffffffffffffffffffffffffffffffff16828661345b565b6040805173ffffffffffffffffffffffffffffffffffffffff831681526020810186905281517f51c9b122c2b81c914282042bf02d3a8965f5a0b1ad37b6dab1cb77bb343ce556929181900390910190a150505050565b60106020526000908152604090205460ff1681565b600f5481565b600a5481565b336000818152600560205260409020546114a457600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116600090815260056020526040812080549190556114d7816134ed565b6002546114fb9073ffffffffffffffffffffffffffffffffffffffff16838361345b565b6002546040805173ffffffffffffffffffffffffffffffffffffffff80861682529092166020830152818101839052517f4831bdd9dcf3048a28319ce81d3cab7a15366bcf449bc7803a539107440809cc9181900360600190a15050565b60056020526000908152604090205481565b600081565b60135473ffffffffffffffffffffffffffffffffffffffff1633146115f657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff821660008181526010602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001685151590811790915582519384529083015280517f0aa5ec5ffdc7f6f9c4d0dded489d7450297155cb2f71cb771e02427f7dff4f519281900390910190a15050565b60135473ffffffffffffffffffffffffffffffffffffffff1681565b600d5481565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60155474010000000000000000000000000000000000000000900460ff168015611725575060135473ffffffffffffffffffffffffffffffffffffffff16331480611725575060155473ffffffffffffffffffffffffffffffffffffffff1633145b61177a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260358152602001806143c26035913960400191505060405180910390fd5b61178482826135ae565b5050565b60135473ffffffffffffffffffffffffffffffffffffffff16331461180e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff811661187a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614503602f913960400191505060405180910390fd5b600254604080517ffc0c546a000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9283169284169163fc0c546a916004808301926020929190829003018186803b1580156118e757600080fd5b505afa1580156118fb573d6000803e3d6000fd5b505050506040513d602081101561191157600080fd5b505173ffffffffffffffffffffffffffffffffffffffff161461197f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806144436021913960400191505060405180910390fd5b6040805180820190915273ffffffffffffffffffffffffffffffffffffffff82168152600060208201526119b590601790613616565b60405173ffffffffffffffffffffffffffffffffffffffff8216907f0821015de34e20b0878a40f6f165801417f53b2017016d7321cacee989c8cfa790600090a250565b60076020526000908152604090205460ff1681565b60066020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260066020526040812054600e548291611a5591906132e7565b600d5473ffffffffffffffffffffffffffffffffffffffff8516600090815260036020526040902054919250611a8f91610ab09084613332565b9392505050565b60155474010000000000000000000000000000000000000000900460ff1681565b60135473ffffffffffffffffffffffffffffffffffffffff163314611b3d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b60128190556040805182815290517fcf837c6f8ba9f94fb0b21939d04aba4ae1cf50cbeca85513c218dfdc6666f1a99181900360200190a150565b60165473ffffffffffffffffffffffffffffffffffffffff1681565b60086020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b60135473ffffffffffffffffffffffffffffffffffffffff163314611c4257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b60008190556040805182815290517fc2965d898897107f6f1d0e43c043ca07b7a51d487acfac1decec2ec8405364409181900360200190a150565b60095481565b600c54600b5443906000908015611cf8576000611ca084866132e7565b90506000548110611cb357819250611cda565b600054611cc08383613332565b1115611cda57600054611cd790610ab08484613332565b92505b8215611cf657611cea82846132e7565b600b55611cf68361367e565b505b600c839055336000611d0982611a20565b90508015611d7857600f54611d1e90826132e7565b600f5573ffffffffffffffffffffffffffffffffffffffff8216600090815260046020526040902054611d5190826133e7565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600460205260409020555b600e5473ffffffffffffffffffffffffffffffffffffffff831660009081526006602090815260408083209390935533825260079052205460ff16611e325760098054600090815260086020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915583526007909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915581540190555b60155474010000000000000000000000000000000000000000900460ff1615611ebc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f656d657267656e637920706175736520656e61626c6564000000000000000000604482015290519081900360640190fd5b6001543390611ee39073ffffffffffffffffffffffffffffffffffffffff1682308b6136e7565b600a54611ef090896133e7565b600a5573ffffffffffffffffffffffffffffffffffffffff8116600090815260036020526040902054611f2390896133e7565b73ffffffffffffffffffffffffffffffffffffffff82166000818152600360209081526040918290209390935580519182529181018a905281517fd2c11ddc796e75881f492256edb3cb3bf4c7a7761682320c5798a8dbb3662d88929181900390910190a15050505050505050565b60046020526000908152604090205481565b60135473ffffffffffffffffffffffffffffffffffffffff16331480611fe1575060155473ffffffffffffffffffffffffffffffffffffffff1633145b61204c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f2128676f76207c7c2073656e74696e656c290000000000000000000000000000604482015290519081900360640190fd5b601580548215157401000000000000000000000000000000000000000081027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff9092169190911790915560408051918252517f77860e247ab9186dbe64e5bd0e0b93273cc4273e01818420e788f500078886f59181900360200190a150565b60135473ffffffffffffffffffffffffffffffffffffffff16331461215157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166121d357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f63616e6e6f74206d69677261746520746f203078300000000000000000000000604482015290519081900360640190fd5b60155474010000000000000000000000000000000000000000900460ff16612246576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806144b86021913960400191505060405180910390fd5b600254604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b1580156122b757600080fd5b505afa1580156122cb573d6000803e3d6000fd5b505050506040513d60208110156122e157600080fd5b5051600a54604080516060810190915260228082529293506000926123129291906143f76020830139849190613782565b600254604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff878116600483015260248201859052915193945091169163095ea7b3916044808201926020929091908290030181600087803b15801561239057600080fd5b505af11580156123a4573d6000803e3d6000fd5b505050506040513d60208110156123ba57600080fd5b5050604080517ffb93210800000000000000000000000000000000000000000000000000000000815230600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff85169163fb93210891604480830192600092919082900301818387803b15801561243057600080fd5b505af1158015612444573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff871681526020810185905281517f491c0362a655f805cc3d5ab67c471c6b4e517051540c85134456449ce6c1a6799450908190039091019150a1505050565b600c54600b54439060009080156125135760006124bb84866132e7565b905060005481106124ce578192506124f5565b6000546124db8383613332565b11156124f5576000546124f290610ab08484613332565b92505b82156125115761250582846132e7565b600b556125118361367e565b505b600c83905533600061252482611a20565b9050801561259357600f5461253990826132e7565b600f5573ffffffffffffffffffffffffffffffffffffffff821660009081526004602052604090205461256c90826133e7565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600460205260409020555b600e5473ffffffffffffffffffffffffffffffffffffffff831660009081526006602052604081209190915587906125ca82611a20565b9050801561263957600f546125df90826132e7565b600f5573ffffffffffffffffffffffffffffffffffffffff821660009081526004602052604090205461261290826133e7565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600460205260409020555b600e5473ffffffffffffffffffffffffffffffffffffffff831660009081526006602090815260408083209390935533825260079052205460ff166126f35760098054600090815260086020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915583526007909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915581540190555b73ffffffffffffffffffffffffffffffffffffffff8916600090815260046020908152604080832054600390925290912054339190811161279557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f5472616e736d757465723a20216f766572666c6f770000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8b16600090815260046020908152604080832083905560039091528120546127d39083906132e7565b73ffffffffffffffffffffffffffffffffffffffff808e1660009081526003602052604080822080549083905560015482517f42966c6800000000000000000000000000000000000000000000000000000000815260048101839052925191975094955093909216926342966c6892602480820193929182900301818387803b15801561285f57600080fd5b505af1158015612873573d6000803e3d6000fd5b5050600a5461288592509050836132e7565b600a5573ffffffffffffffffffffffffffffffffffffffff83166000908152600460205260409020546128b890826133e7565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260046020908152604080832094909455918f168152600590915220546128fb90836133e7565b73ffffffffffffffffffffffffffffffffffffffff8d16600090815260056020526040902081905561292c816134ed565b73ffffffffffffffffffffffffffffffffffffffff808e1660009081526005602052604081205560025461296291168e8361345b565b6040805173ffffffffffffffffffffffffffffffffffffffff80871682528f16602082015280820183905290517fb1e35379b2ed6821c33158f59080978024478baafa855571cd84e46b9848b3ce9181900360600190a150505050505050505050505050565b60155474010000000000000000000000000000000000000000900460ff168015612a2a575060135473ffffffffffffffffffffffffffffffffffffffff16331480612a2a575060155473ffffffffffffffffffffffffffffffffffffffff1633145b612a7f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260358152602001806143c26035913960400191505060405180910390fd5b612a8881613833565b50565b60008080612a9a601785613899565b6016549091506000908190612ac690849073ffffffffffffffffffffffffffffffffffffffff166138c0565b604080518381526020810183905281519395509193507f11d2034f4471d11a13f0f1798ceaf0c9db2812d450a0681958ce7d4f2fb97f0992918290030190a1909350915050915091565b612b18612cb2565b612b2061148b565b33600090815260036020526040902054612a888161127a565b612b20612cb2565b60135473ffffffffffffffffffffffffffffffffffffffff163314612bc757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f5472616e736d757465723a2021676f7665726e616e6365000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116612c33576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614419602a913960400191505060405180910390fd5b6016805473ffffffffffffffffffffffffffffffffffffffff83167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f05f3326e0527f309d4015dee3bc3f36e650b53fc823bab69c99847814acfafdf9181900360200190a150565b600b5481565b600c54600b5443906000908015612d27576000612ccf84866132e7565b90506000548110612ce257819250612d09565b600054612cef8383613332565b1115612d0957600054612d0690610ab08484613332565b92505b8215612d2557612d1982846132e7565b600b55612d258361367e565b505b600c839055336000612d3882611a20565b90508015612da757600f54612d4d90826132e7565b600f5573ffffffffffffffffffffffffffffffffffffffff8216600090815260046020526040902054612d8090826133e7565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600460205260409020555b600e5473ffffffffffffffffffffffffffffffffffffffff8316600090815260066020908152604080832093909355338083526004909152918120549081612e5057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f6e65656420746f20686176652070656e64696e6720696e206275636b65740000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526004602090815260408083208390556003909152902054821115612ee65773ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040902054612ebb9083906132e7565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260036020526040902054925090505b73ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040902054612f1690836132e7565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600360205260408082209390935560015483517f42966c680000000000000000000000000000000000000000000000000000000081526004810187905293519216926342966c68926024808301939282900301818387803b158015612f9757600080fd5b505af1158015612fab573d6000803e3d6000fd5b5050600a54612fbd92509050836132e7565b600a55612fc98161367e565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260056020526040902054612ff990836133e7565b73ffffffffffffffffffffffffffffffffffffffff841660008181526005602090815260409182902093909355805191825291810184905281517fe6b1330a9c444712d3673f05900d736c42072653e56fb82b5951477832b8d576929181900390910190a1505050505050505050565b60145473ffffffffffffffffffffffffffffffffffffffff1681565b60155473ffffffffffffffffffffffffffffffffffffffff1681565b60036020526000908152604090205481565b3360009081526010602052604090205460ff1661313157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f5472616e736d757465723a202177686974656c69737465640000000000000000604482015290519081900360640190fd5b600c54600b54439060009080156131a657600061314e84866132e7565b9050600054811061316157819250613188565b60005461316e8383613332565b11156131885760005461318590610ab08484613332565b92505b82156131a45761319882846132e7565b600b556131a48361367e565b505b600c83905560155474010000000000000000000000000000000000000000900460ff161561323557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f656d657267656e637920706175736520656e61626c6564000000000000000000604482015290519081900360640190fd5b60025461325a9073ffffffffffffffffffffffffffffffffffffffff168730886136e7565b600b5461326790866133e7565b600b55613272613913565b6040805173ffffffffffffffffffffffffffffffffffffffff881681526020810187905281517f33ad5d6b2a46b5457e0d36286a2686a0390b0821dedbbdf8dcdcda64f4782c68929181900390910190a1505050505050565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b600061332983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613782565b90505b92915050565b6000826133415750600061332c565b8282028284828161334e57fe5b0414613329576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806144646021913960400191505060405180910390fd5b600061332983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613a2b565b60008282018381101561332957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526134e8908490613aaa565b505050565b600254604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b15801561355e57600080fd5b505afa158015613572573d6000803e3d6000fd5b505050506040513d602081101561358857600080fd5b505190508181101561178457601154818303906134e8906135a990836133e7565b613b82565b60006135bb601784613899565b90506000806135cb833086613bb8565b91509150847fccbd929f935422b28ee209a0db0556280b0a3d9bc4da58f1d3f0ab4f8a4996478383604051808381526020018281526020019250505060405180910390a25050505050565b8154600180820184556000938452602093849020835160029093020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9093169290921782559190920151910155565b6000600a541180156136905750600081115b156136d4576136bc6136b3600a54610ab0600d548561333290919063ffffffff16565b600e54906133e7565b600e55600f546136cc90826133e7565b600f55612a88565b600b546136e190826133e7565b600b5550565b6040805173ffffffffffffffffffffffffffffffffffffffff80861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261377c908590613aaa565b50505050565b6000818484111561382b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156137f05781810151838201526020016137d8565b50505050905090810190601f16801561381d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000613840601783613899565b905060008061384f8330613bee565b91509150837fccbd929f935422b28ee209a0db0556280b0a3d9bc4da58f1d3f0ab4f8a4996478383604051808381526020018281526020019250505060405180910390a250505050565b60008260000182815481106138aa57fe5b9060005260206000209060020201905092915050565b60008083600101546138d185613c15565b116138e157506000905080610c47565b60006138fa85600101546138f487613c15565b906132e7565b9050613907858583613cb1565b92509250509250929050565b600254604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b15801561398457600080fd5b505afa158015613998573d6000803e3d6000fd5b505050506040513d60208110156139ae57600080fd5b50516012546011549192506000916139cc91606491610ab091613332565b6011549091506139dc90826133e7565b821115613a0857601154820360006139f46017613ec8565b9050613a008183613ef3565b505050611784565b601154613a1590826132e7565b821015611784576011548290036134e881613b82565b60008183613a94576040517f08c379a00000000000000000000000000000000000000000000000000000000081526020600482018181528351602484015283519092839260449091019190850190808383600083156137f05781810151838201526020016137d8565b506000838581613aa057fe5b0495945050505050565b6060613b0c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16613fd09092919063ffffffff16565b8051909150156134e857808060200190516020811015613b2b57600080fd5b50516134e8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806144d9602a913960400191505060405180910390fd5b6000613b8e6017613ec8565b90506000613b9b82613c15565b905082811015613ba9578092505b82156134e8576134e883613fe7565b6000808080613bc8878787613ffa565b60018901549193509150613bdc90826132e7565b60018801559092509050935093915050565b600080613c0a83856001015486613bb89092919063ffffffff16565b915091509250929050565b8054604080517fd4c3eea0000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163d4c3eea0916004808301926020929190829003018186803b158015613c7f57600080fd5b505afa158015613c93573d6000803e3d6000fd5b505050506040513d6020811015613ca957600080fd5b505192915050565b6000806000613cbf86614128565b905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231876040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015613d2a57600080fd5b505afa158015613d3e573d6000803e3d6000fd5b505050506040513d6020811015613d5457600080fd5b505190506000613d6388613c15565b8854604080517f594d4e3600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b81166004830152602482018b9052915193945091169163594d4e369160448082019260009290919082900301818387803b158015613ddf57600080fd5b505af1158015613df3573d6000803e3d6000fd5b5050505060008373ffffffffffffffffffffffffffffffffffffffff166370a08231896040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015613e6057600080fd5b505afa158015613e74573d6000803e3d6000fd5b505050506040513d6020811015613e8a57600080fd5b505190506000613e9a82856132e7565b90506000613ea78b613c15565b90506000613eb585836132e7565b929c929b50919950505050505050505050565b600081613ed481614192565b81548110613ede57fe5b90600052602060002090600202019050919050565b600080613eff84614128565b8454909150613f289073ffffffffffffffffffffffffffffffffffffffff80841691168561345b565b8354604080517fb6b55f2500000000000000000000000000000000000000000000000000000000815260048101869052905173ffffffffffffffffffffffffffffffffffffffff9092169163b6b55f259160248082019260009290919082900301818387803b158015613f9a57600080fd5b505af1158015613fae573d6000803e3d6000fd5b5050506001850154613fc19150846133e7565b60018501555081905092915050565b6060613fdf84846000856141eb565b949350505050565b612a88613ff46017614192565b826135ae565b600080600061400886614128565b905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231876040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561407357600080fd5b505afa158015614087573d6000803e3d6000fd5b505050506040513d602081101561409d57600080fd5b5051905060006140ac88613c15565b8854604080517ff3fef3a300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b81166004830152602482018b9052915193945091169163f3fef3a39160448082019260009290919082900301818387803b158015613ddf57600080fd5b8054604080517ffc0c546a000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163fc0c546a916004808301926020929190829003018186803b158015613c7f57600080fd5b60008061419e836143b7565b9050611a8f60016040518060400160405280601181526020017f5661756c742e4c6973743a20656d707479000000000000000000000000000000815250836137829092919063ffffffff16565b60606141f6856143bb565b61426157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106142cb57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161428e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461432d576040519150601f19603f3d011682016040523d82523d6000602084013e614332565b606091505b50915091508115614346579150613fdf9050565b8051156143565780518082602001fd5b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526020600482018181528651602484015286518793919283926044019190850190808383600083156137f05781810151838201526020016137d8565b5490565b3b15159056fe5472616e736d757465723a206e6f74207061757365642c206f72206e6f7420676f7665726e616e6365206f722073656e74696e656c6e6f7420656e6f7567682066756e647320746f2073657276696365207374616b65735472616e736d757465723a207265776172647320616464726573732063616e6e6f74206265203078302e5472616e736d757465722e7661756c743a20746f6b656e206d69736d617463682e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775472616e736d757465723a20756e7374616b6520616d6f756e742065786365656473206465706f736974656420616d6f756e746d6967726174653a2073657420656d657267656e637920657869742066697273745361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645472616e736d757465723a20616374697665207661756c7420616464726573732063616e6e6f74206265203078302e5472616e736d757465723a2073656e74696e656c20616464726573732063616e6e6f74206265203078302ea26469706673582212201385980ceed86fc65f4e73a482f0594b8a6c44adc51d412fda8f49689a5f2c6164736f6c634300060c0033
[ 4, 7, 37, 9, 12, 13, 5, 2 ]
0xf3d04a98595f0f4d9a08b19f17638efb19378859
/** *Submitted for verification at Etherscan.io on 2020-09-29 */ 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); } /** * @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 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"); } } /** * @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"); } } } /** * @dev Contract module that helps prevent reentrant calls to a function. */ contract ReentrancyGuard { bool private _notEntered; constructor () internal { // Storing an initial 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 percetange 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. _notEntered = true; } /** * @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(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } } contract OwnerContract { address payable public _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () public { _owner = msg.sender; } /** * @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 msg.sender == _owner; } } /** * @title Crowdsale * @dev Crowdsale is a base contract for managing a token crowdsale, * allowing investors to purchase tokens with ether. This contract implements * such functionality in its most fundamental form and can be extended to provide additional * functionality and/or custom behavior. * The external interface represents the basic interface for purchasing tokens, and conforms * the base architecture for crowdsales. It is *not* intended to be modified / overridden. * The internal interface conforms the extensible and modifiable surface of crowdsales. Override * the methods to add functionality. Consider using 'super' where appropriate to concatenate * behavior. */ contract SpartanCrowdsale is ReentrancyGuard, OwnerContract { using SafeMath for uint256; using SafeERC20 for IERC20; // The token being sold IERC20 private _token; // Address where funds are collected address payable private _wallet; // How many token units a buyer gets per wei. // The rate is the conversion between wei and the smallest and indivisible token unit. // So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK // 1 wei will give you 1 unit, or 0.001 TOK. uint256 private _rate; // Amount of wei raised uint256 private _weiRaised; /** * Event for token purchase logging * @param purchaser who paid for the tokens * @param beneficiary who got the tokens * @param value weis paid for purchase * @param amount amount of tokens purchased */ event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); /** * @param rate Number of token units a buyer gets per wei * @dev The rate is the conversion between wei and the smallest and indivisible * token unit. So, if you are using a rate of 1 with a ERC20Detailed token * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK. * @param wallet Address where collected funds will be forwarded to * @param token Address of the token being sold */ constructor (uint256 rate, address payable wallet, IERC20 token) public { require(rate > 0, "Crowdsale: rate is 0"); require(wallet != address(0), "Crowdsale: wallet is the zero address"); require(address(token) != address(0), "Crowdsale: token is the zero address"); _rate = rate; _wallet = wallet; _token = token; } /** * @dev fallback function ***DO NOT OVERRIDE*** * Note that other contracts will transfer funds with a base gas stipend * of 2300, which is not enough to call buyTokens. Consider calling * buyTokens directly when purchasing tokens from a contract. */ function () external payable { buyTokens(msg.sender); } /** * @return the token being sold. */ function token() public view returns (IERC20) { return _token; } /** * @return the address where funds are collected. */ function wallet() public view returns (address payable) { return _wallet; } /** * @return the number of token units a buyer gets per wei. */ function rate() public view returns (uint256) { return _rate; } /** * @return the amount of wei raised. */ function weiRaised() public view returns (uint256) { return _weiRaised; } /** * @dev low level token purchase ***DO NOT OVERRIDE*** * This function has a non-reentrancy guard, so it shouldn't be called by * another `nonReentrant` function. * @param beneficiary Recipient of the token purchase */ function buyTokens(address beneficiary) public nonReentrant payable { uint256 weiAmount = msg.value; _preValidatePurchase(beneficiary, weiAmount); // calculate token amount to be created uint256 tokens = _getTokenAmount(weiAmount); // update state _weiRaised = _weiRaised.add(weiAmount); _processPurchase(beneficiary, tokens); emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens); _updatePurchasingState(beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(beneficiary, weiAmount); } /** * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. * Use `super` in contracts that inherit from Crowdsale to extend their validations. * Example from CappedCrowdsale.sol's _preValidatePurchase method: * super._preValidatePurchase(beneficiary, weiAmount); * require(weiRaised().add(weiAmount) <= cap); * @param beneficiary Address performing the token purchase * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { require(beneficiary != address(0), "Crowdsale: beneficiary is the zero address"); require(weiAmount != 0, "Crowdsale: weiAmount is 0"); this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 } /** * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid * conditions are not met. * @param beneficiary Address performing the token purchase * @param weiAmount Value in wei involved in the purchase */ function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view { // solhint-disable-previous-line no-empty-blocks } /** * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends * its tokens. * @param beneficiary Address performing the token purchase * @param tokenAmount Number of tokens to be emitted */ function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { _token.safeTransfer(beneficiary, tokenAmount); } /** * @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send * tokens. * @param beneficiary Address receiving the tokens * @param tokenAmount Number of tokens to be purchased */ function _processPurchase(address beneficiary, uint256 tokenAmount) internal { _deliverTokens(beneficiary, tokenAmount); } /** * @dev Override for extensions that require an internal state to check for validity (current user contributions, * etc.) * @param beneficiary Address receiving the tokens * @param weiAmount Value in wei involved in the purchase */ function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { // solhint-disable-previous-line no-empty-blocks } /** * @dev Override to extend the way in which ether is converted to tokens. * @param weiAmount Value in wei to be converted into tokens * @return Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { return weiAmount.mul(_rate); } /** * @dev Determines how ETH is stored/forwarded on purchases. */ function _forwardFunds() internal { _wallet.transfer(msg.value); } function changeRate(uint256 new_rate) public nonReentrant{ require(msg.sender == _owner); _rate = new_rate; } function changeToken(IERC20 new_token) public nonReentrant{ require(msg.sender == _owner); _token = new_token; } function changeWallet(address payable new_wallet) public nonReentrant{ require(msg.sender == _owner); _wallet = new_wallet; } function transferAllToken(uint256 tokenAmount) public nonReentrant{ require(msg.sender == _owner); _deliverTokens(msg.sender, tokenAmount); } } contract SpartanPresale is SpartanCrowdsale { constructor ( uint256 rate, address payable wallet, IERC20 token ) public SpartanCrowdsale(rate, wallet, token) { } }
0x60806040526004361061009c5760003560e01c80638f32d59b116100645780638f32d59b146101e057806398b9a2dc1461020f578063b2bdfa7b14610260578063cb1977e3146102b7578063ec8ac4d8146102f2578063fc0c546a146103365761009c565b80632c4e722e146100a75780634042b66f146100d2578063521eb273146100fd57806366829b161461015457806374e7493b146101a5575b6100a53361038d565b005b3480156100b357600080fd5b506100bc610511565b6040518082815260200191505060405180910390f35b3480156100de57600080fd5b506100e761051b565b6040518082815260200191505060405180910390f35b34801561010957600080fd5b50610112610525565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561016057600080fd5b506101a36004803603602081101561017757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054f565b005b3480156101b157600080fd5b506101de600480360360208110156101c857600080fd5b81019080803590602001909291905050506106a2565b005b3480156101ec57600080fd5b506101f56107bb565b604051808215151515815260200191505060405180910390f35b34801561021b57600080fd5b5061025e6004803603602081101561023257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610812565b005b34801561026c57600080fd5b50610275610965565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102c357600080fd5b506102f0600480360360208110156102da57600080fd5b810190808035906020019092919050505061098b565b005b6103346004803603602081101561030857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061038d565b005b34801561034257600080fd5b5061034b610aa7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000809054906101000a900460ff1661040e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60008060006101000a81548160ff02191690831515021790555060003490506104378282610ad1565b600061044282610bd2565b905061045982600454610bf090919063ffffffff16565b6004819055506104698382610c78565b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f6faf93231a456e552dbc9961f58d9713ee4f2e69d15f1975b050ef0911053a7b8484604051808381526020018281526020019250505060405180910390a36104e08383610c86565b6104e8610c8a565b6104f28383610cf5565b505060016000806101000a81548160ff02191690831515021790555050565b6000600354905090565b6000600454905090565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900460ff166105d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60008060006101000a81548160ff021916908315150217905550600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461064457600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016000806101000a81548160ff02191690831515021790555050565b6000809054906101000a900460ff16610723576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60008060006101000a81548160ff021916908315150217905550600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461079757600080fd5b8060038190555060016000806101000a81548160ff02191690831515021790555050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b6000809054906101000a900460ff16610893576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60008060006101000a81548160ff021916908315150217905550600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461090757600080fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016000806101000a81548160ff02191690831515021790555050565b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900460ff16610a0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0081525060200191505060405180910390fd5b60008060006101000a81548160ff021916908315150217905550600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a8057600080fd5b610a8a3382610cf9565b60016000806101000a81548160ff02191690831515021790555050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b57576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611159602a913960400191505060405180910390fd5b6000811415610bce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f43726f776473616c653a20776569416d6f756e7420697320300000000000000081525060200191505060405180910390fd5b5050565b6000610be960035483610d4a90919063ffffffff16565b9050919050565b600080828401905083811015610c6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610c828282610cf9565b5050565b5050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610cf2573d6000803e3d6000fd5b50565b5050565b610d468282600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610dd09092919063ffffffff16565b5050565b600080831415610d5d5760009050610dca565b6000828402905082848281610d6e57fe5b0414610dc5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806111386021913960400191505060405180910390fd5b809150505b92915050565b610e9c838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610ea1565b505050565b610ec08273ffffffffffffffffffffffffffffffffffffffff166110ec565b610f32576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310610f815780518252602082019150602081019050602083039250610f5e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610fe3576040519150601f19603f3d011682016040523d82523d6000602084013e610fe8565b606091505b509150915081611060576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b6000815111156110e65780806020019051602081101561107f57600080fd5b81019080805190602001909291905050506110e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611183602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561112e57506000801b8214155b9250505091905056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743726f776473616c653a2062656e656669636961727920697320746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a723158206a70303cd230e053a38318acc6338c8041a8cd512dfe2f58d1c93bdb5a6c6a2764736f6c63430005110032
[ 38 ]
0xf3d05e481e1f7baaa32759e3218e8cce270f4a50
// File: contracts/interfaces/IMerkleDistributor.sol pragma solidity >=0.5.0; // Allows anyone to claim a token if they exist in a merkle root. interface IMerkleDistributor { // Returns the address of the token distributed by this contract. function token() external view returns (address); // Returns the merkle root of the merkle tree containing account balances available to claim. function merkleRoot() external view returns (bytes32); // Returns true if the index has been marked claimed. function isClaimed(uint256 index) external view returns (bool); // Claim the given amount of the token to the given address. Reverts if the inputs are invalid. function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external; // This event is triggered whenever a call to #claim succeeds. event Claimed(uint256 index, address account, uint256 amount); } // File: contracts/MerkleProof.sol pragma solidity =0.8.4; /** * @dev These functions deal with verification of Merkle trees (hash trees), */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash < proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol // OpenZeppelin Contracts v4.4.0 (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/MerkleDistributor.sol pragma solidity =0.8.4; //import "./MerkleProof.sol"; contract MerkleDistributor is IMerkleDistributor { address public immutable override token; bytes32 public immutable override merkleRoot; using SafeERC20 for IERC20; // This is a packed array of booleans. mapping(uint256 => uint256) private claimedBitMap; constructor(address token_, bytes32 merkleRoot_) public { token = token_; merkleRoot = merkleRoot_; } function isClaimed(uint256 index) public view override returns (bool) { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; uint256 claimedWord = claimedBitMap[claimedWordIndex]; uint256 mask = (1 << claimedBitIndex); return claimedWord & mask == mask; } function _setClaimed(uint256 index) private { uint256 claimedWordIndex = index / 256; uint256 claimedBitIndex = index % 256; claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex); } function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override { require(!isClaimed(index), 'MerkleDistributor: Drop already claimed.'); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(index, account, amount)); require(MerkleProof.verify(merkleProof, merkleRoot, node), 'MerkleDistributor: Invalid proof.'); // Mark it claimed and send the token. _setClaimed(index); //require(IERC20(token).transfer(account, amount), 'MerkleDistributor: Transfer failed.'); SafeERC20.safeTransfer(IERC20(token), account, amount); emit Claimed(index, account, amount); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80632e7ba6ef146100515780632eb4a7ab1461006d5780639e34070f1461008b578063fc0c546a146100bb575b600080fd5b61006b60048036038101906100669190610813565b6100d9565b005b610075610273565b6040516100829190610b0c565b60405180910390f35b6100a560048036038101906100a091906107ea565b610297565b6040516100b29190610af1565b60405180910390f35b6100c36102ec565b6040516100d09190610aad565b60405180910390f35b6100e285610297565b15610122576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011990610b49565b60405180910390fd5b600085858560405160200161013993929190610a70565b6040516020818303038152906040528051906020012090506101bd838380806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050507f75beb3666ff6eda52607e79d06fc646c644180ede7d44ce15df02e0ae29294a183610310565b6101fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101f390610b89565b60405180910390fd5b610205866103ed565b6102307f000000000000000000000000a5b947687163fe88c3e6af5b17ae69896f4abccf8686610445565b7f4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed02686868660405161026393929190610be9565b60405180910390a1505050505050565b7f75beb3666ff6eda52607e79d06fc646c644180ede7d44ce15df02e0ae29294a181565b600080610100836102a89190610c52565b90506000610100846102ba9190610d89565b905060008060008481526020019081526020016000205490506000826001901b90508081831614945050505050919050565b7f000000000000000000000000a5b947687163fe88c3e6af5b17ae69896f4abccf81565b60008082905060005b85518110156103df57600086828151811061035d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190508083101561039f578281604051602001610382929190610a2d565b6040516020818303038152906040528051906020012092506103cb565b80836040516020016103b2929190610a2d565b6040516020818303038152906040528051906020012092505b5080806103d790610d08565b915050610319565b508381149150509392505050565b6000610100826103fd9190610c52565b905060006101008361040f9190610d89565b9050806001901b600080848152602001908152602001600020541760008084815260200190815260200160002081905550505050565b6104c68363a9059cbb60e01b8484604051602401610464929190610ac8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506104cb565b505050565b600061052d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166105929092919063ffffffff16565b905060008151111561058d578080602001905181019061054d91906107c1565b61058c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058390610bc9565b60405180910390fd5b5b505050565b60606105a184846000856105aa565b90509392505050565b6060824710156105ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e690610b69565b60405180910390fd5b6105f8856106be565b610637576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062e90610ba9565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106609190610a59565b60006040518083038185875af1925050503d806000811461069d576040519150601f19603f3d011682016040523d82523d6000602084013e6106a2565b606091505b50915091506106b28282866106d1565b92505050949350505050565b600080823b905060008111915050919050565b606083156106e157829050610731565b6000835111156106f45782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107289190610b27565b60405180910390fd5b9392505050565b60008135905061074781610f9b565b92915050565b60008083601f84011261075f57600080fd5b8235905067ffffffffffffffff81111561077857600080fd5b60208301915083602082028301111561079057600080fd5b9250929050565b6000815190506107a681610fb2565b92915050565b6000813590506107bb81610fc9565b92915050565b6000602082840312156107d357600080fd5b60006107e184828501610797565b91505092915050565b6000602082840312156107fc57600080fd5b600061080a848285016107ac565b91505092915050565b60008060008060006080868803121561082b57600080fd5b6000610839888289016107ac565b955050602061084a88828901610738565b945050604061085b888289016107ac565b935050606086013567ffffffffffffffff81111561087857600080fd5b6108848882890161074d565b92509250509295509295909350565b61089c81610c83565b82525050565b6108b36108ae82610c83565b610d51565b82525050565b6108c281610c95565b82525050565b6108d181610ca1565b82525050565b6108e86108e382610ca1565b610d63565b82525050565b60006108f982610c20565b6109038185610c36565b9350610913818560208601610cd5565b80840191505092915050565b600061092a82610c2b565b6109348185610c41565b9350610944818560208601610cd5565b61094d81610e18565b840191505092915050565b6000610965602883610c41565b915061097082610e36565b604082019050919050565b6000610988602683610c41565b915061099382610e85565b604082019050919050565b60006109ab602183610c41565b91506109b682610ed4565b604082019050919050565b60006109ce601d83610c41565b91506109d982610f23565b602082019050919050565b60006109f1602a83610c41565b91506109fc82610f4c565b604082019050919050565b610a1081610ccb565b82525050565b610a27610a2282610ccb565b610d7f565b82525050565b6000610a3982856108d7565b602082019150610a4982846108d7565b6020820191508190509392505050565b6000610a6582846108ee565b915081905092915050565b6000610a7c8286610a16565b602082019150610a8c82856108a2565b601482019150610a9c8284610a16565b602082019150819050949350505050565b6000602082019050610ac26000830184610893565b92915050565b6000604082019050610add6000830185610893565b610aea6020830184610a07565b9392505050565b6000602082019050610b0660008301846108b9565b92915050565b6000602082019050610b2160008301846108c8565b92915050565b60006020820190508181036000830152610b41818461091f565b905092915050565b60006020820190508181036000830152610b6281610958565b9050919050565b60006020820190508181036000830152610b828161097b565b9050919050565b60006020820190508181036000830152610ba28161099e565b9050919050565b60006020820190508181036000830152610bc2816109c1565b9050919050565b60006020820190508181036000830152610be2816109e4565b9050919050565b6000606082019050610bfe6000830186610a07565b610c0b6020830185610893565b610c186040830184610a07565b949350505050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610c5d82610ccb565b9150610c6883610ccb565b925082610c7857610c77610de9565b5b828204905092915050565b6000610c8e82610cab565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610cf3578082015181840152602081019050610cd8565b83811115610d02576000848401525b50505050565b6000610d1382610ccb565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610d4657610d45610dba565b5b600182019050919050565b6000610d5c82610d6d565b9050919050565b6000819050919050565b6000610d7882610e29565b9050919050565b6000819050919050565b6000610d9482610ccb565b9150610d9f83610ccb565b925082610daf57610dae610de9565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4d65726b6c654469737472696275746f723a2044726f7020616c72656164792060008201527f636c61696d65642e000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f4d65726b6c654469737472696275746f723a20496e76616c69642070726f6f6660008201527f2e00000000000000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b610fa481610c83565b8114610faf57600080fd5b50565b610fbb81610c95565b8114610fc657600080fd5b50565b610fd281610ccb565b8114610fdd57600080fd5b5056fea264697066735822122041ffec6c66d7649875208b685f19834d489f7ce50f211cbdd782c280ad31d05364736f6c63430008040033
[ 38 ]
0xf3d0bd1a445a90d1cd38bca87b6e43db88c14f9a
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.4; /// @title StaticMulticall based on UniswapV3 Multicall at 0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696 /// @author Aleph Retamal <github.com/alephao> /// @notice Modified (UniswapV3 Multicall).aggregate to be a `view` fn. /// Using staticcall instead of call and if it fails, return the error contract StaticMulticall { error CallError(bytes err); struct Call { address target; bytes callData; } struct Result { bool success; bytes returnData; } function aggregate(Call[] memory calls) external view returns (uint256 blockNumber, bytes[] memory returnData) { blockNumber = block.number; returnData = new bytes[](calls.length); for(uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory ret) = calls[i].target.staticcall(calls[i].callData); if (!success) { revert CallError(ret); } returnData[i] = ret; } } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063252dba4214610030575b600080fd5b61004361003e366004610227565b61005a565b6040516100519291906103f0565b60405180910390f35b8051439060609067ffffffffffffffff811115610079576100796101b7565b6040519080825280602002602001820160405280156100ac57816020015b60608152602001906001900390816100975790505b50905060005b83518110156101b1576000808583815181106100d0576100d061045a565b6020026020010151600001516001600160a01b03168684815181106100f7576100f761045a565b6020026020010151602001516040516101109190610470565b600060405180830381855afa9150503d806000811461014b576040519150601f19603f3d011682016040523d82523d6000602084013e610150565b606091505b50915091508161017e5780604051630e0b9a0160e01b8152600401610175919061048c565b60405180910390fd5b808484815181106101915761019161045a565b6020026020010181905250505080806101a9906104a6565b9150506100b2565b50915091565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156101f0576101f06101b7565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561021f5761021f6101b7565b604052919050565b6000602080838503121561023a57600080fd5b823567ffffffffffffffff8082111561025257600080fd5b818501915085601f83011261026657600080fd5b813581811115610278576102786101b7565b8060051b6102878582016101f6565b91825283810185019185810190898411156102a157600080fd5b86860192505b83831015610387578235858111156102bf5760008081fd5b86016040601f19828d0381018213156102d85760008081fd5b6102e06101cd565b838b01356001600160a01b03811681146102fa5760008081fd5b8152838301358981111561030e5760008081fd5b8085019450508d603f8501126103245760008081fd5b8a84013589811115610338576103386101b7565b6103488c84601f840116016101f6565b92508083528e8482870101111561035f5760008081fd5b808486018d85013760009083018c0152808b01919091528452505091860191908601906102a7565b9998505050505050505050565b60005b838110156103af578181015183820152602001610397565b838111156103be576000848401525b50505050565b600081518084526103dc816020860160208601610394565b601f01601f19169290920160200192915050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b8281101561044c57605f1988870301845261043a8683516103c4565b9550928401929084019060010161041e565b509398975050505050505050565b634e487b7160e01b600052603260045260246000fd5b60008251610482818460208701610394565b9190910192915050565b60208152600061049f60208301846103c4565b9392505050565b60006000198214156104c857634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220e355f9377949c6bf4641923c440139218ebdf5deac91027c2a7bb131283c5d4164736f6c634300080b0033
[ 38 ]
0xF3D127dB17136deA1887dfbAfdbBF8Ee1177f1aa
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "@openzeppelin/contracts/token/ERC777/ERC777.sol"; contract Token is ERC777 { address[] private NO_DEFAULT_OPERATORS; constructor(string memory name, string memory symbol, uint256 totalSupply) ERC777(name, symbol, NO_DEFAULT_OPERATORS) { _mint(msg.sender, totalSupply * 10 ** 18, "", ""); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the global ERC1820 Registry, as defined in the * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register * implementers for interfaces in this registry, as well as query support. * * Implementers may be shared by multiple accounts, and can also implement more * than a single interface for each account. Contracts can implement interfaces * for themselves, but externally-owned accounts (EOA) must delegate this to a * contract. * * {IERC165} interfaces can also be queried via the registry. * * For an in-depth explanation and source code analysis, see the EIP text. */ interface IERC1820Registry { /** * @dev Sets `newManager` as the manager for `account`. A manager of an * account is able to set interface implementers for it. * * By default, each account is its own manager. Passing a value of `0x0` in * `newManager` will reset the manager to this initial state. * * Emits a {ManagerChanged} event. * * Requirements: * * - the caller must be the current manager for `account`. */ function setManager(address account, address newManager) external; /** * @dev Returns the manager for `account`. * * See {setManager}. */ function getManager(address account) external view returns (address); /** * @dev Sets the `implementer` contract as ``account``'s implementer for * `interfaceHash`. * * `account` being the zero address is an alias for the caller's address. * The zero address can also be used in `implementer` to remove an old one. * * See {interfaceHash} to learn how these are created. * * Emits an {InterfaceImplementerSet} event. * * Requirements: * * - the caller must be the current manager for `account`. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not * end in 28 zeroes). * - `implementer` must implement {IERC1820Implementer} and return true when * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ function setInterfaceImplementer( address account, bytes32 _interfaceHash, address implementer ) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such * implementer is registered, returns the zero address. * * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 * zeroes), `account` will be queried for support of it. * * `account` being the zero address is an alias for the caller's address. */ function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address); /** * @dev Returns the interface hash for an `interfaceName`, as defined in the * corresponding * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. */ function interfaceHash(string calldata interfaceName) external pure returns (bytes32); /** * @notice Updates the cache with whether the contract implements an ERC165 interface or not. * @param account Address of the contract for which to update the cache. * @param interfaceId ERC165 interface for which to update the cache. */ function updateERC165Cache(address account, bytes4 interfaceId) external; /** * @notice Checks whether a contract implements an ERC165 interface or not. * If the result is not cached a direct lookup on the contract address is performed. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling * {updateERC165Cache} with the contract address. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); /** * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); event ManagerChanged(address indexed account, address indexed newManager); } // 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 ERC777TokensSender standard as defined in the EIP. * * {IERC777} Token holders can be notified of operations performed on their * tokens by having a contract implement this interface (contract holders can be * their own implementer) and registering it on the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. * * See {IERC1820Registry} and {ERC1820Implementer}. */ interface IERC777Sender { /** * @dev Called by an {IERC777} token contract whenever a registered holder's * (`from`) tokens are about to be moved or destroyed. The type of operation * is conveyed by `to` being the zero address or not. * * This call occurs _before_ the token contract's state is updated, so * {IERC777-balanceOf}, etc., can be used to query the pre-operation state. * * This function may revert to prevent the operation from being executed. */ function tokensToSend( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. * * Accounts can be notified of {IERC777} tokens being sent to them by having a * contract implement this interface (contract holders can be their own * implementer) and registering it on the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. * * See {IERC1820Registry} and {ERC1820Implementer}. */ interface IERC777Recipient { /** * @dev Called by an {IERC777} token contract whenever tokens are being * moved or created into a registered account (`to`). The type of operation * is conveyed by `from` being the zero address or not. * * This call occurs _after_ the token contract's state is updated, so * {IERC777-balanceOf}, etc., can be used to query the post-operation state. * * This function may revert to prevent the operation from being executed. */ function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC777Token standard as defined in the EIP. * * This contract uses the * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 registry standard] to let * token holders and recipients react to token movements by using setting implementers * for the associated interfaces in said registry. See {IERC1820Registry} and * {ERC1820Implementer}. */ interface IERC777 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() external view returns (string memory); /** * @dev Returns the smallest part of the token that is not divisible. This * means all token operations (creation, movement and destruction) must have * amounts that are a multiple of this number. * * For most token contracts, this value will equal 1. */ function granularity() external view returns (uint256); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by an account (`owner`). */ function balanceOf(address owner) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * If send or receive hooks are registered for the caller and `recipient`, * the corresponding functions will be called with `data` and empty * `operatorData`. See {IERC777Sender} and {IERC777Recipient}. * * Emits a {Sent} event. * * Requirements * * - the caller must have at least `amount` tokens. * - `recipient` cannot be the zero address. * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ function send( address recipient, uint256 amount, bytes calldata data ) external; /** * @dev Destroys `amount` tokens from the caller's account, reducing the * total supply. * * If a send hook is registered for the caller, the corresponding function * will be called with `data` and empty `operatorData`. See {IERC777Sender}. * * Emits a {Burned} event. * * Requirements * * - the caller must have at least `amount` tokens. */ function burn(uint256 amount, bytes calldata data) external; /** * @dev Returns true if an account is an operator of `tokenHolder`. * Operators can send and burn tokens on behalf of their owners. All * accounts are their own operator. * * See {operatorSend} and {operatorBurn}. */ function isOperatorFor(address operator, address tokenHolder) external view returns (bool); /** * @dev Make an account an operator of the caller. * * See {isOperatorFor}. * * Emits an {AuthorizedOperator} event. * * Requirements * * - `operator` cannot be calling address. */ function authorizeOperator(address operator) external; /** * @dev Revoke an account's operator status for the caller. * * See {isOperatorFor} and {defaultOperators}. * * Emits a {RevokedOperator} event. * * Requirements * * - `operator` cannot be calling address. */ function revokeOperator(address operator) external; /** * @dev Returns the list of default operators. These accounts are operators * for all token holders, even if {authorizeOperator} was never called on * them. * * This list is immutable, but individual holders may revoke these via * {revokeOperator}, in which case {isOperatorFor} will return false. */ function defaultOperators() external view returns (address[] memory); /** * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must * be an operator of `sender`. * * If send or receive hooks are registered for `sender` and `recipient`, * the corresponding functions will be called with `data` and * `operatorData`. See {IERC777Sender} and {IERC777Recipient}. * * Emits a {Sent} event. * * Requirements * * - `sender` cannot be the zero address. * - `sender` must have at least `amount` tokens. * - the caller must be an operator for `sender`. * - `recipient` cannot be the zero address. * - if `recipient` is a contract, it must implement the {IERC777Recipient} * interface. */ function operatorSend( address sender, address recipient, uint256 amount, bytes calldata data, bytes calldata operatorData ) external; /** * @dev Destroys `amount` tokens from `account`, reducing the total supply. * The caller must be an operator of `account`. * * If a send hook is registered for `account`, the corresponding function * will be called with `data` and `operatorData`. See {IERC777Sender}. * * Emits a {Burned} event. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. * - the caller must be an operator for `account`. */ function operatorBurn( address account, uint256 amount, bytes calldata data, bytes calldata operatorData ) external; event Sent( address indexed operator, address indexed from, address indexed to, uint256 amount, bytes data, bytes operatorData ); event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData); event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData); event AuthorizedOperator(address indexed operator, address indexed tokenHolder); event RevokedOperator(address indexed operator, address indexed tokenHolder); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC777.sol"; import "./IERC777Recipient.sol"; import "./IERC777Sender.sol"; import "../ERC20/IERC20.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/IERC1820Registry.sol"; /** * @dev Implementation of the {IERC777} 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}. * * Support for ERC20 is included in this contract, as specified by the EIP: both * the ERC777 and ERC20 interfaces can be safely used when interacting with it. * Both {IERC777-Sent} and {IERC20-Transfer} events are emitted on token * movements. * * Additionally, the {IERC777-granularity} value is hard-coded to `1`, meaning that there * are no special restrictions in the amount of tokens that created, moved, or * destroyed. This makes integration with ERC20 applications seamless. */ contract ERC777 is Context, IERC777, IERC20 { using Address for address; IERC1820Registry internal constant _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); mapping(address => uint256) private _balances; uint256 private _totalSupply; string private _name; string private _symbol; bytes32 private constant _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender"); bytes32 private constant _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient"); // This isn't ever read from - it's only used to respond to the defaultOperators query. address[] private _defaultOperatorsArray; // Immutable, but accounts may revoke them (tracked in __revokedDefaultOperators). mapping(address => bool) private _defaultOperators; // For each account, a mapping of its operators and revoked default operators. mapping(address => mapping(address => bool)) private _operators; mapping(address => mapping(address => bool)) private _revokedDefaultOperators; // ERC20-allowances mapping(address => mapping(address => uint256)) private _allowances; /** * @dev `defaultOperators` may be an empty array. */ constructor( string memory name_, string memory symbol_, address[] memory defaultOperators_ ) { _name = name_; _symbol = symbol_; _defaultOperatorsArray = defaultOperators_; for (uint256 i = 0; i < defaultOperators_.length; i++) { _defaultOperators[defaultOperators_[i]] = true; } // register interfaces _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this)); _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this)); } /** * @dev See {IERC777-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC777-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {ERC20-decimals}. * * Always returns 18, as per the * [ERC777 EIP](https://eips.ethereum.org/EIPS/eip-777#backward-compatibility). */ function decimals() public pure virtual returns (uint8) { return 18; } /** * @dev See {IERC777-granularity}. * * This implementation always returns `1`. */ function granularity() public view virtual override returns (uint256) { return 1; } /** * @dev See {IERC777-totalSupply}. */ function totalSupply() public view virtual override(IERC20, IERC777) returns (uint256) { return _totalSupply; } /** * @dev Returns the amount of tokens owned by an account (`tokenHolder`). */ function balanceOf(address tokenHolder) public view virtual override(IERC20, IERC777) returns (uint256) { return _balances[tokenHolder]; } /** * @dev See {IERC777-send}. * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ function send( address recipient, uint256 amount, bytes memory data ) public virtual override { _send(_msgSender(), recipient, amount, data, "", true); } /** * @dev See {IERC20-transfer}. * * Unlike `send`, `recipient` is _not_ required to implement the {IERC777Recipient} * interface if it is a contract. * * Also emits a {Sent} event. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { require(recipient != address(0), "ERC777: transfer to the zero address"); address from = _msgSender(); _callTokensToSend(from, from, recipient, amount, "", ""); _move(from, from, recipient, amount, "", ""); _callTokensReceived(from, from, recipient, amount, "", "", false); return true; } /** * @dev See {IERC777-burn}. * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ function burn(uint256 amount, bytes memory data) public virtual override { _burn(_msgSender(), amount, data, ""); } /** * @dev See {IERC777-isOperatorFor}. */ function isOperatorFor(address operator, address tokenHolder) public view virtual override returns (bool) { return operator == tokenHolder || (_defaultOperators[operator] && !_revokedDefaultOperators[tokenHolder][operator]) || _operators[tokenHolder][operator]; } /** * @dev See {IERC777-authorizeOperator}. */ function authorizeOperator(address operator) public virtual override { require(_msgSender() != operator, "ERC777: authorizing self as operator"); if (_defaultOperators[operator]) { delete _revokedDefaultOperators[_msgSender()][operator]; } else { _operators[_msgSender()][operator] = true; } emit AuthorizedOperator(operator, _msgSender()); } /** * @dev See {IERC777-revokeOperator}. */ function revokeOperator(address operator) public virtual override { require(operator != _msgSender(), "ERC777: revoking self as operator"); if (_defaultOperators[operator]) { _revokedDefaultOperators[_msgSender()][operator] = true; } else { delete _operators[_msgSender()][operator]; } emit RevokedOperator(operator, _msgSender()); } /** * @dev See {IERC777-defaultOperators}. */ function defaultOperators() public view virtual override returns (address[] memory) { return _defaultOperatorsArray; } /** * @dev See {IERC777-operatorSend}. * * Emits {Sent} and {IERC20-Transfer} events. */ function operatorSend( address sender, address recipient, uint256 amount, bytes memory data, bytes memory operatorData ) public virtual override { require(isOperatorFor(_msgSender(), sender), "ERC777: caller is not an operator for holder"); _send(sender, recipient, amount, data, operatorData, true); } /** * @dev See {IERC777-operatorBurn}. * * Emits {Burned} and {IERC20-Transfer} events. */ function operatorBurn( address account, uint256 amount, bytes memory data, bytes memory operatorData ) public virtual override { require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder"); _burn(account, amount, data, operatorData); } /** * @dev See {IERC20-allowance}. * * Note that operator and allowance concepts are orthogonal: operators may * not have allowance, and accounts with allowance may not be operators * themselves. */ function allowance(address holder, address spender) public view virtual override returns (uint256) { return _allowances[holder][spender]; } /** * @dev See {IERC20-approve}. * * Note that accounts cannot have allowance issued by their operators. */ function approve(address spender, uint256 value) public virtual override returns (bool) { address holder = _msgSender(); _approve(holder, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Note that operator and allowance concepts are orthogonal: operators cannot * call `transferFrom` (unless they have allowance), and accounts with * allowance cannot call `operatorSend` (unless they are operators). * * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. */ function transferFrom( address holder, address recipient, uint256 amount ) public virtual override returns (bool) { require(recipient != address(0), "ERC777: transfer to the zero address"); require(holder != address(0), "ERC777: transfer from the zero address"); address spender = _msgSender(); _callTokensToSend(spender, holder, recipient, amount, "", ""); _move(spender, holder, recipient, amount, "", ""); uint256 currentAllowance = _allowances[holder][spender]; require(currentAllowance >= amount, "ERC777: transfer amount exceeds allowance"); _approve(holder, spender, currentAllowance - amount); _callTokensReceived(spender, holder, recipient, amount, "", "", false); return true; } /** * @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * If a send hook is registered for `account`, the corresponding function * will be called with `operator`, `data` and `operatorData`. * * See {IERC777Sender} and {IERC777Recipient}. * * Emits {Minted} and {IERC20-Transfer} events. * * Requirements * * - `account` cannot be the zero address. * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ function _mint( address account, uint256 amount, bytes memory userData, bytes memory operatorData ) internal virtual { _mint(account, amount, userData, operatorData, true); } /** * @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * If `requireReceptionAck` is set to true, and if a send hook is * registered for `account`, the corresponding function will be called with * `operator`, `data` and `operatorData`. * * See {IERC777Sender} and {IERC777Recipient}. * * Emits {Minted} and {IERC20-Transfer} events. * * Requirements * * - `account` cannot be the zero address. * - if `account` is a contract, it must implement the {IERC777Recipient} * interface. */ function _mint( address account, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) internal virtual { require(account != address(0), "ERC777: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, amount); // Update state variables _totalSupply += amount; _balances[account] += amount; _callTokensReceived(operator, address(0), account, amount, userData, operatorData, requireReceptionAck); emit Minted(operator, account, amount, userData, operatorData); emit Transfer(address(0), account, amount); } /** * @dev Send tokens * @param from address token holder address * @param to address recipient address * @param amount uint256 amount of tokens to transfer * @param userData bytes extra information provided by the token holder (if any) * @param operatorData bytes extra information provided by the operator (if any) * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient */ function _send( address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) internal virtual { require(from != address(0), "ERC777: send from the zero address"); require(to != address(0), "ERC777: send to the zero address"); address operator = _msgSender(); _callTokensToSend(operator, from, to, amount, userData, operatorData); _move(operator, from, to, amount, userData, operatorData); _callTokensReceived(operator, from, to, amount, userData, operatorData, requireReceptionAck); } /** * @dev Burn tokens * @param from address token holder address * @param amount uint256 amount of tokens to burn * @param data bytes extra information provided by the token holder * @param operatorData bytes extra information provided by the operator (if any) */ function _burn( address from, uint256 amount, bytes memory data, bytes memory operatorData ) internal virtual { require(from != address(0), "ERC777: burn from the zero address"); address operator = _msgSender(); _callTokensToSend(operator, from, address(0), amount, data, operatorData); _beforeTokenTransfer(operator, from, address(0), amount); // Update state variables uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC777: burn amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _totalSupply -= amount; emit Burned(operator, from, amount, data, operatorData); emit Transfer(from, address(0), amount); } function _move( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData ) private { _beforeTokenTransfer(operator, from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC777: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Sent(operator, from, to, amount, userData, operatorData); emit Transfer(from, to, amount); } /** * @dev See {ERC20-_approve}. * * Note that accounts cannot have allowance issued by their operators. */ function _approve( address holder, address spender, uint256 value ) internal { require(holder != address(0), "ERC777: approve from the zero address"); require(spender != address(0), "ERC777: approve to the zero address"); _allowances[holder][spender] = value; emit Approval(holder, spender, value); } /** * @dev Call from.tokensToSend() if the interface is registered * @param operator address operator requesting the transfer * @param from address token holder address * @param to address recipient address * @param amount uint256 amount of tokens to transfer * @param userData bytes extra information provided by the token holder (if any) * @param operatorData bytes extra information provided by the operator (if any) */ function _callTokensToSend( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData ) private { address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(from, _TOKENS_SENDER_INTERFACE_HASH); if (implementer != address(0)) { IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData); } } /** * @dev Call to.tokensReceived() if the interface is registered. Reverts if the recipient is a contract but * tokensReceived() was not registered for the recipient * @param operator address operator requesting the transfer * @param from address token holder address * @param to address recipient address * @param amount uint256 amount of tokens to transfer * @param userData bytes extra information provided by the token holder (if any) * @param operatorData bytes extra information provided by the operator (if any) * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient */ function _callTokensReceived( address operator, address from, address to, uint256 amount, bytes memory userData, bytes memory operatorData, bool requireReceptionAck ) private { address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(to, _TOKENS_RECIPIENT_INTERFACE_HASH); if (implementer != address(0)) { IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); } else if (requireReceptionAck) { require(!to.isContract(), "ERC777: token recipient contract has no implementer for ERC777TokensRecipient"); } } /** * @dev Hook that is called before any token transfer. This includes * calls to {send}, {transfer}, {operatorSend}, 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 operator, 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); }
0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063959b8c3f116100b2578063d95b637111610081578063fad8b32a11610066578063fad8b32a14610297578063fc673c4f146102aa578063fe9d9303146102bd57600080fd5b8063d95b63711461024b578063dd62ed3e1461025e57600080fd5b8063959b8c3f1461020a57806395d89b411461021d5780639bd9bbc614610225578063a9059cbb1461023857600080fd5b806323b872dd11610109578063556f0dc7116100ee578063556f0dc7146101c557806362ad1b83146101cc57806370a08231146101e157600080fd5b806323b872dd146101a3578063313ce567146101b657600080fd5b806306e485381461013b57806306fdde0314610159578063095ea7b31461016e57806318160ddd14610191575b600080fd5b6101436102d0565b60405161015091906118a9565b60405180910390f35b610161610332565b60405161015091906118f6565b61018161017c3660046116b7565b6103bb565b6040519015158152602001610150565b6001545b604051908152602001610150565b6101816101b13660046115e3565b6103d3565b60405160128152602001610150565b6001610195565b6101df6101da366004611624565b610618565b005b6101956101ef366004611570565b6001600160a01b031660009081526020819052604090205490565b6101df610218366004611570565b6106aa565b6101616107e1565b6101df6102333660046116e3565b6107f0565b6101816102463660046116b7565b610813565b6101816102593660046115aa565b61091b565b61019561026c3660046115aa565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b6101df6102a5366004611570565b6109bd565b6101df6102b836600461173c565b610af5565b6101df6102cb3660046117bc565b610b83565b6060600480548060200260200160405190810160405280929190818152602001828054801561032857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161030a575b5050505050905090565b6060600280546103419061196d565b80601f016020809104026020016040519081016040528092919081815260200182805461036d9061196d565b80156103285780601f1061038f57610100808354040283529160200191610328565b820191906000526020600020905b81548152906001019060200180831161039d57509395945050505050565b6000336103c9818585610ba8565b5060019392505050565b60006001600160a01b0383166104555760405162461bcd60e51b8152602060048201526024808201527f4552433737373a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6001600160a01b0384166104d15760405162461bcd60e51b815260206004820152602660248201527f4552433737373a207472616e736665722066726f6d20746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161044c565b6000339050610502818686866040518060200160405280600081525060405180602001604052806000815250610d01565b61052e818686866040518060200160405280600081525060405180602001604052806000815250610e6a565b6001600160a01b03808616600090815260086020908152604080832093851683529290522054838110156105ca5760405162461bcd60e51b815260206004820152602960248201527f4552433737373a207472616e7366657220616d6f756e7420657863656564732060448201527f616c6c6f77616e63650000000000000000000000000000000000000000000000606482015260840161044c565b6105de86836105d98785611956565b610ba8565b61060c8287878760405180602001604052806000815250604051806020016040528060008152506000610fe6565b50600195945050505050565b610622338661091b565b6106945760405162461bcd60e51b815260206004820152602c60248201527f4552433737373a2063616c6c6572206973206e6f7420616e206f70657261746f60448201527f7220666f7220686f6c6465720000000000000000000000000000000000000000606482015260840161044c565b6106a3858585858560016111fc565b5050505050565b336001600160a01b03821614156107285760405162461bcd60e51b8152602060048201526024808201527f4552433737373a20617574686f72697a696e672073656c66206173206f70657260448201527f61746f7200000000000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b03811660009081526005602052604090205460ff1615610779573360009081526007602090815260408083206001600160a01b03851684529091529020805460ff191690556107a8565b3360009081526006602090815260408083206001600160a01b03851684529091529020805460ff191660011790555b60405133906001600160a01b038316907ff4caeb2d6ca8932a215a353d0703c326ec2d81fc68170f320eb2ab49e9df61f990600090a350565b6060600380546103419061196d565b61080e338484846040518060200160405280600081525060016111fc565b505050565b60006001600160a01b0383166108905760405162461bcd60e51b8152602060048201526024808201527f4552433737373a207472616e7366657220746f20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161044c565b60003390506108c1818286866040518060200160405280600081525060405180602001604052806000815250610d01565b6108ed818286866040518060200160405280600081525060405180602001604052806000815250610e6a565b6103c98182868660405180602001604052806000815250604051806020016040528060008152506000610fe6565b6000816001600160a01b0316836001600160a01b0316148061098657506001600160a01b03831660009081526005602052604090205460ff16801561098657506001600160a01b0380831660009081526007602090815260408083209387168352929052205460ff16155b806109b657506001600160a01b0380831660009081526006602090815260408083209387168352929052205460ff165b9392505050565b6001600160a01b038116331415610a3c5760405162461bcd60e51b815260206004820152602160248201527f4552433737373a207265766f6b696e672073656c66206173206f70657261746f60448201527f7200000000000000000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b03811660009081526005602052604090205460ff1615610a90573360009081526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610abc565b3360009081526006602090815260408083206001600160a01b03851684529091529020805460ff191690555b60405133906001600160a01b038316907f50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa190600090a350565b610aff338561091b565b610b715760405162461bcd60e51b815260206004820152602c60248201527f4552433737373a2063616c6c6572206973206e6f7420616e206f70657261746f60448201527f7220666f7220686f6c6465720000000000000000000000000000000000000000606482015260840161044c565b610b7d848484846112fa565b50505050565b610b9e338383604051806020016040528060008152506112fa565b5050565b3b151590565b6001600160a01b038316610c245760405162461bcd60e51b815260206004820152602560248201527f4552433737373a20617070726f76652066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b038216610ca05760405162461bcd60e51b815260206004820152602360248201527f4552433737373a20617070726f766520746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b0383811660008181526008602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6040517faabbb8ca0000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201527f29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe8956024820152600090731820a4b7618bde71dce8cdc73aab6c95905fad249063aabbb8ca9060440160206040518083038186803b158015610d9657600080fd5b505afa158015610daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dce919061158d565b90506001600160a01b03811615610e61576040517f75ab97820000000000000000000000000000000000000000000000000000000081526001600160a01b038216906375ab978290610e2e908a908a908a908a908a908a90600401611850565b600060405180830381600087803b158015610e4857600080fd5b505af1158015610e5c573d6000803e3d6000fd5b505050505b50505050505050565b6001600160a01b03851660009081526020819052604090205483811015610ef95760405162461bcd60e51b815260206004820152602760248201527f4552433737373a207472616e7366657220616d6f756e7420657863656564732060448201527f62616c616e636500000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b03808716600090815260208190526040808220878503905591871681529081208054869290610f3090849061193e565b92505081905550846001600160a01b0316866001600160a01b0316886001600160a01b03167f06b541ddaa720db2b10a4d0cdac39b8d360425fc073085fac19bc82614677987878787604051610f8893929190611909565b60405180910390a4846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef86604051610fd591815260200190565b60405180910390a350505050505050565b6040517faabbb8ca0000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201527fb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b6024820152600090731820a4b7618bde71dce8cdc73aab6c95905fad249063aabbb8ca9060440160206040518083038186803b15801561107b57600080fd5b505afa15801561108f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b3919061158d565b90506001600160a01b03811615611148576040517e23de290000000000000000000000000000000000000000000000000000000081526001600160a01b038216906223de2990611111908b908b908b908b908b908b90600401611850565b600060405180830381600087803b15801561112b57600080fd5b505af115801561113f573d6000803e3d6000fd5b505050506111f2565b81156111f2576001600160a01b0386163b156111f25760405162461bcd60e51b815260206004820152604d60248201527f4552433737373a20746f6b656e20726563697069656e7420636f6e747261637460448201527f20686173206e6f20696d706c656d656e74657220666f7220455243373737546f60648201527f6b656e73526563697069656e7400000000000000000000000000000000000000608482015260a40161044c565b5050505050505050565b6001600160a01b0386166112785760405162461bcd60e51b815260206004820152602260248201527f4552433737373a2073656e642066726f6d20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b0385166112ce5760405162461bcd60e51b815260206004820181905260248201527f4552433737373a2073656e6420746f20746865207a65726f2061646472657373604482015260640161044c565b336112dd818888888888610d01565b6112eb818888888888610e6a565b610e6181888888888888610fe6565b6001600160a01b0384166113765760405162461bcd60e51b815260206004820152602260248201527f4552433737373a206275726e2066726f6d20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161044c565b3361138681866000878787610d01565b6001600160a01b038516600090815260208190526040902054848110156114155760405162461bcd60e51b815260206004820152602360248201527f4552433737373a206275726e20616d6f756e7420657863656564732062616c6160448201527f6e63650000000000000000000000000000000000000000000000000000000000606482015260840161044c565b6001600160a01b0386166000908152602081905260408120868303905560018054879290611444908490611956565b92505081905550856001600160a01b0316826001600160a01b03167fa78a9be3a7b862d26933ad85fb11d80ef66b8f972d7cbba06621d583943a409887878760405161149293929190611909565b60405180910390a36040518581526000906001600160a01b038816907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050505050565b600082601f8301126114f457600080fd5b813567ffffffffffffffff8082111561150f5761150f6119be565b604051601f8301601f19908116603f01168101908282118183101715611537576115376119be565b8160405283815286602085880101111561155057600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561158257600080fd5b81356109b6816119d4565b60006020828403121561159f57600080fd5b81516109b6816119d4565b600080604083850312156115bd57600080fd5b82356115c8816119d4565b915060208301356115d8816119d4565b809150509250929050565b6000806000606084860312156115f857600080fd5b8335611603816119d4565b92506020840135611613816119d4565b929592945050506040919091013590565b600080600080600060a0868803121561163c57600080fd5b8535611647816119d4565b94506020860135611657816119d4565b935060408601359250606086013567ffffffffffffffff8082111561167b57600080fd5b61168789838a016114e3565b9350608088013591508082111561169d57600080fd5b506116aa888289016114e3565b9150509295509295909350565b600080604083850312156116ca57600080fd5b82356116d5816119d4565b946020939093013593505050565b6000806000606084860312156116f857600080fd5b8335611703816119d4565b925060208401359150604084013567ffffffffffffffff81111561172657600080fd5b611732868287016114e3565b9150509250925092565b6000806000806080858703121561175257600080fd5b843561175d816119d4565b935060208501359250604085013567ffffffffffffffff8082111561178157600080fd5b61178d888389016114e3565b935060608701359150808211156117a357600080fd5b506117b0878288016114e3565b91505092959194509250565b600080604083850312156117cf57600080fd5b82359150602083013567ffffffffffffffff8111156117ed57600080fd5b6117f9858286016114e3565b9150509250929050565b6000815180845260005b818110156118295760208185018101518683018201520161180d565b8181111561183b576000602083870101525b50601f01601f19169290920160200192915050565b60006001600160a01b038089168352808816602084015280871660408401525084606083015260c0608083015261188a60c0830185611803565b82810360a084015261189c8185611803565b9998505050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156118ea5783516001600160a01b0316835292840192918401916001016118c5565b50909695505050505050565b6020815260006109b66020830184611803565b8381526060602082015260006119226060830185611803565b82810360408401526119348185611803565b9695505050505050565b60008219821115611951576119516119a8565b500190565b600082821015611968576119686119a8565b500390565b600181811c9082168061198157607f821691505b602082108114156119a257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146119e957600080fd5b5056fea2646970667358221220864e35b118532932f2b7f92cf39c136d2e1dd54f37165aa2f2134a53080cad9964736f6c63430008070033
[ 0 ]
0xf3d13419a03E794dD536d1d8FD6575DE5781c31F
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; interface ICoolCats { function ownerOf(uint256 tokenId) external returns (address); } //.............................................................................. //.............................................................................. //.............................................................................. //......................................&&&&&&&................................. //...................................&&****&&***&&&&............................ //..................................&****&....&&***&&........................... //.................................&&***&&......&&&............................. //..........................&&&&****&****&*******%&&&........................... //......................&&*****************************&&....................... //....................&&*********************************&&..................... //..................&&***&&&&&***********&&&&&&************&.................... //.................&&**& &&*******&& .&**********&&................... //.................&&*&& && &&*****&& && &&**********&................... //.................&&*&& &&*******&& &&**********&&................... //..................&&***&&&&***&&&&*&&***&&&&***********(&&.................... //...................&&&*******************************(%&...................... //..................&&&&#*********************************&&&................... //...............&&&**&&**************************************&&................ //.............&&****&&***********&&****************&&**&******&&............... //............&&**&&&&***********&&(&&*************/(((&&*******&............... //...........&&***&&&&((********&%((((&***********(((((&********&&.............. //...........&*&&&&&&&*********&&(((((&&*************&&*******&& &.............. //...........&**&*& &&(*********&&(((&&*************&&****&&& &&&&**#&.......... //............&&&&...&&*****************************&**&& &&********&&.......... //.....................&&&******************************&&******/&&&&........... //........................&&*******&&%/***************&&&&&&&& &.&&&............ //.........................&&******&&.......&&*******&&......................... //...........................&&&&&&...........&&&&&&&........................... //.............................................................................. //.............................................................................. // ........................ [ In memory of Duhtred ] .......................... // ............................................................................. contract CoolPets is ERC721, Ownable { using ECDSA for bytes32; // Addresses address public _ccAddress; address public _w1 = 0x1fFa3371A45C22B1284fE5a251eD64F40580a1E3; address public _systemAddress = address(0); // Token mint values uint256 public constant MAX_PET_ID = 19999; // Track minting outside of Cool Cat ids. uint256 public _currentPetId = 9999; // for giveaways, staff and partnerships uint256 public _reserved = 100; bytes32 public _merkleRoot = 0x0; uint256 public _price = 0.5 ether; bool public _claimsPaused = true; bool public _merkleLocked = false; string public _baseTokenURI; // For bit manipulation uint256[] _allowListTicketSlots; // Handle public mint access enum EPublicMintStatus { CLOSED, RESERVED_MINT, ALLOW_LIST, OPEN } EPublicMintStatus public _publicMintStatus; // Tracks if address has minted mapping(address => bool) public _minted; // Genetics: petId => genetics mapping(uint256 => bytes32) public _petGenetics; constructor(string memory baseURI, address ccContractAddress) ERC721("Test Cool Pets", "TPETS") { _baseTokenURI = baseURI; _ccAddress = ccContractAddress; } /// @notice Adopt via public minting /// @dev Id tracking starts at 9999 to prevent id contamination /// @dev Signature to help avoid bot minting /// @param salt Some simple salting for the signature /// @param signature Verify that this transaction came from the desired location function publicAdopt(uint256 salt, bytes memory signature) external payable { uint256 currentPetId = _currentPetId; require(msg.sender == tx.origin, "CP: We like real users"); require(_publicMintStatus == EPublicMintStatus.OPEN, "CP: Minting closed"); require(currentPetId < MAX_PET_ID, "CP: Exceeds maximum Pet supply"); require(msg.value == _price, "CP: Invalid Eth sent"); require(_minted[msg.sender] == false, "CP: Address has minted a pet"); // Mark address as minted _minted[msg.sender] = true; // verify require(_isValidSignature(keccak256(abi.encodePacked(msg.sender, salt)), signature), "CP: Invalid signature"); // Pets bought by non-cat holders will have token ID increasing from 9,999 onwards, after cat and allow list holders _mint(msg.sender, currentPetId); unchecked { currentPetId++; } _currentPetId = currentPetId; } /// @notice Adopt via allow list with reference to a ticket number + merkle tree /// @dev Id tracking starts at 9999 to prevent id contamination /// @dev We could allow contracts to mint but saving gas for users is more important /// @dev Dont start ticketNumber at 0 /// @param merkleProof Merkle proof for verifcation /// @param ticketNumber ticket number assigned to user's address function allowListAdopt(bytes32[] calldata merkleProof, uint256 ticketNumber) external payable { uint256 currentPetId = _currentPetId; require(msg.sender == tx.origin, "CP: We like real users"); require(_publicMintStatus == EPublicMintStatus.ALLOW_LIST, "CP: Allow list closed"); require(msg.value == _price, "CP: Invalid Eth sent"); // Merkle magic bytes32 leaf = keccak256(abi.encodePacked(msg.sender, ticketNumber)); require(MerkleProof.verify(merkleProof, _merkleRoot, leaf), "CP: Invalid merkle proof"); // claim ticket _claimTicket(ticketNumber); // Pets bought by non-cat holders will have token ID increasing from 9,999 onwards _mint(msg.sender, currentPetId); unchecked { currentPetId++; } _currentPetId = currentPetId; } /// @notice To check and track ticket numbers being claimed against /// @dev Returns error if ticket is larger than range or has been claimed against /// @dev Uses bit manipulation in place of mapping /// @dev https://medium.com/donkeverse/hardcore-gas-savings-in-nft-minting-part-3-save-30-000-in-presale-gas-c945406e89f0 /// @param ticketNumber ticket number assigned to user's address function _claimTicket(uint256 ticketNumber) internal { require(ticketNumber < _allowListTicketSlots.length * 256, "CP: Invalid ticket"); uint256 storageOffset; // [][][] uint256 localGroup; // [][x][] uint256 offsetWithin256; // 0xF[x]FFF // We can trust the admin arent adding silly numbers - we hope :P unchecked { storageOffset = ticketNumber / 256; offsetWithin256 = ticketNumber % 256; } localGroup = _allowListTicketSlots[storageOffset]; // [][x][] > 0x1111[x]1111 > 1 require((localGroup >> offsetWithin256) & uint256(1) == 1, "CP: Ticket claimed"); // [][x][] > 0x1111[x]1111 > (1) flip to (0) localGroup = localGroup & ~(uint256(1) << offsetWithin256); _allowListTicketSlots[storageOffset] = localGroup; } /// @notice Adopt N pets against cat Ids /// @dev Allows for users to select specific cats to claim against /// @dev Requires cat ownership to mint /// @dev Takes in an array of CC tokenIds to allow option for users with multiple cats to choose which to claim against /// @dev Checks tokenIds items against ERC721's _exist(id) function prior to mint /// @param tokenIds Array of CC tokenIds to be claimed against function adoptNPets(uint256[] memory tokenIds) external { require(msg.sender == tx.origin, "CP: We like real users"); require(!_claimsPaused, "CP: Claiming paused"); // Check if user is adopting less than 51 pets to avoid gassing out require(tokenIds.length < 51, "CP: Adoption limit is 50"); ICoolCats memCats = ICoolCats(_ccAddress); for (uint256 i; i < tokenIds.length; i++) { uint256 catId = tokenIds[i]; // Only cat owner can mint pets that dont already exist for their corresponding cat id // Gas loss prevention, for less careful users if (memCats.ownerOf(catId) == msg.sender && !_exists(catId)) { _mint(msg.sender, catId); } } } /// @notice Let Admin mint out 100 pets for giveaways and collabs function reservedMint() external onlyOwner { uint256 currentPetId = _currentPetId; uint256 reserved = _reserved; require(_publicMintStatus == EPublicMintStatus.RESERVED_MINT, "CP: Reserved mint closed"); require(reserved > 0, "CP: No more reserve mints left"); for (uint256 i; i < 20; i++) { _mint(msg.sender, currentPetId++); } _currentPetId = currentPetId; reserved -= 20; _reserved = reserved; } /// @notice Pause claiming of pets by cat holders /// @param val True or false function pauseClaim(bool val) external onlyOwner { _claimsPaused = val; } /// @notice Change the public minting status /// @param status Status to change to function setPublicMintStatus(uint256 status) external onlyOwner { require(status <= uint256(EPublicMintStatus.OPEN), "CP: Out of bounds"); _publicMintStatus = EPublicMintStatus(status); } /// @notice Sets the mint data slot length that tracks the state of tickets /// @param num number of tickets available for allow list function setMintSlotLength(uint256 num) external onlyOwner { // Prevents us from over filling the Allow List require(_currentPetId + num <= MAX_PET_ID, "CP: More tickets than pets"); // account for solidity rounding down uint256 slotCount = (num / 256) + 1; // set each element in the slot to binaries of 1 uint256 MAX_INT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; // create a temporary array based on number of slots required uint256[] memory arr = new uint256[](slotCount); // fill each element with MAX_INT for (uint256 i; i < slotCount; i++) { arr[i] = MAX_INT; } _allowListTicketSlots = arr; } /// @notice Set baseURI /// @param baseURI URI of the pet image server function setBaseURI(string memory baseURI) external onlyOwner { _baseTokenURI = baseURI; } /// @notice Get uri of tokens /// @return string Uri function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } /// @notice Set the purchase price of pets /// @param newPrice In wei - 10 ** 18 function setPrice(uint256 newPrice) external onlyOwner { _price = newPrice; } /// @notice Set final genetics of a single pet /// @param id Id of the pet in question /// @param genes Genetics details of pet in question function setGenetics(uint256 id, bytes32 genes) external onlyOwner { _petGenetics[id] = genes; } /// @notice Set the system address /// @param systemAddress Address to set as systemAddress function setSystemAddress(address systemAddress) external onlyOwner { _systemAddress = systemAddress; } /// @notice Se the Cool Cats contract address /// @param ccAddress Address of the Cool Cats contract function setCoolCatsAddress(address ccAddress) external onlyOwner { _ccAddress = ccAddress; } /// @notice Set withdrawal address /// @param wallet Address of withdrawal target function setWithdrawalWallet(address wallet) external onlyOwner { _w1 = wallet; } /// @notice Set new Merkle Root /// @param merkleRoot Root of merkle tree function setMerkleRoot(bytes32 merkleRoot) external onlyOwner { require(!_merkleLocked, "CP: Merkle tree is locked"); _merkleRoot = merkleRoot; } /// @notice Get genetics for this cat - future use (maybe :)) /// @param id Id of the pet in question /// @return genes Genetics of the desired pet function getGenetics(uint256 id) external view returns (bytes32 genes) { return _petGenetics[id]; } /// @notice Verify hashed data /// param hash Hashed data bundle /// @param signature Signature to check hash against /// @return bool Is verified or not function _isValidSignature(bytes32 hash, bytes memory signature) internal view returns (bool) { require(_systemAddress != address(0), "CP: Invalid system address"); bytes32 signedHash = hash.toEthSignedMessageHash(); return signedHash.recover(signature) == _systemAddress; } /// @notice Withdraw funds from contract function withdraw() external payable onlyOwner { payable(_w1).transfer(address(this).balance); } /// @notice Lock the merkle tree so it can not be edited function lockMerkle() external onlyOwner { _merkleLocked = true; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/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 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102885760003560e01c80637de77ecc1161015a578063b1e4edda116100c1578063e4d6b5ff1161007a578063e4d6b5ff14610791578063e5554d58146107a7578063e985e9c5146107c7578063f2274df314610810578063f2fde38b14610823578063fa1d6d1a1461084357600080fd5b8063b1e4edda146106d5578063b5225c6514610702578063b88d4fde1461071c578063c87b56dd1461073c578063cfc86f7b1461075c578063dd23ef061461077157600080fd5b80639b2858a2116101135780639b2858a214610615578063a002233414610642578063a22cb46514610662578063a2b3b17e14610682578063ae262afe146106a2578063ae3aab3b146106b557600080fd5b80637de77ecc1461055d5780638da5cb5b1461058d57806391b7f5ed146105ab57806395d89b41146105cb5780639888cc83146105e057806398994de31461060057600080fd5b806347608412116101fe5780636aaa571d116101b75780636aaa571d146104bd5780636e04b2b0146104d357806370a08231146104e8578063715018a61461050857806375796f761461051d5780637cb647591461053d57600080fd5b806347608412146104005780634f72431614610416578063503dc1791461043d57806355f804b31461045d5780636352211e1461047d5780636881c3e91461049d57600080fd5b80631a2ff46d116102505780631a2ff46d1461035e578063235b6ea11461037e57806323b872dd146103a25780632fc37ab2146103c25780633ccfd60b146103d857806342842e0e146103e057600080fd5b806301ffc9a71461028d57806306210197146102c257806306fdde03146102e4578063081812fc14610306578063095ea7b31461033e575b600080fd5b34801561029957600080fd5b506102ad6102a8366004612d69565b610862565b60405190151581526020015b60405180910390f35b3480156102ce57600080fd5b506102e26102dd366004612aa0565b6108b4565b005b3480156102f057600080fd5b506102f9610909565b6040516102b99190612f0d565b34801561031257600080fd5b50610326610321366004612d51565b61099b565b6040516001600160a01b0390911681526020016102b9565b34801561034a57600080fd5b506102e2610359366004612bee565b610a30565b34801561036a57600080fd5b506102e2610379366004612aa0565b610b46565b34801561038a57600080fd5b50610394600d5481565b6040519081526020016102b9565b3480156103ae57600080fd5b506102e26103bd366004612b10565b610b92565b3480156103ce57600080fd5b50610394600c5481565b6102e2610bc3565b3480156103ec57600080fd5b506102e26103fb366004612b10565b610c29565b34801561040c57600080fd5b50610394614e1f81565b34801561042257600080fd5b506011546104309060ff1681565b6040516102b99190612ee5565b34801561044957600080fd5b506102e2610458366004612c8f565b610c44565b34801561046957600080fd5b506102e2610478366004612da1565b610e18565b34801561048957600080fd5b50610326610498366004612d51565b610e59565b3480156104a957600080fd5b50600754610326906001600160a01b031681565b3480156104c957600080fd5b50610394600b5481565b3480156104df57600080fd5b506102e2610ed0565b3480156104f457600080fd5b50610394610503366004612aa0565b61100f565b34801561051457600080fd5b506102e2611096565b34801561052957600080fd5b506102e2610538366004612aa0565b6110cc565b34801561054957600080fd5b506102e2610558366004612d51565b611118565b34801561056957600080fd5b506102ad610578366004612aa0565b60126020526000908152604090205460ff1681565b34801561059957600080fd5b506006546001600160a01b0316610326565b3480156105b757600080fd5b506102e26105c6366004612d51565b61119f565b3480156105d757600080fd5b506102f96111ce565b3480156105ec57600080fd5b506102e26105fb366004612d37565b6111dd565b34801561060c57600080fd5b506102e261121a565b34801561062157600080fd5b50610394610630366004612d51565b60136020526000908152604090205481565b34801561064e57600080fd5b50600854610326906001600160a01b031681565b34801561066e57600080fd5b506102e261067d366004612bba565b611255565b34801561068e57600080fd5b506102e261069d366004612d51565b611260565b6102e26106b0366004612c19565b6113c0565b3480156106c157600080fd5b506102e26106d0366004612d51565b611582565b3480156106e157600080fd5b506103946106f0366004612d51565b60009081526013602052604090205490565b34801561070e57600080fd5b50600e546102ad9060ff1681565b34801561072857600080fd5b506102e2610737366004612b50565b611643565b34801561074857600080fd5b506102f9610757366004612d51565b61167b565b34801561076857600080fd5b506102f9611756565b34801561077d57600080fd5b506102e261078c366004612de7565b6117e4565b34801561079d57600080fd5b50610394600a5481565b3480156107b357600080fd5b50600954610326906001600160a01b031681565b3480156107d357600080fd5b506102ad6107e2366004612ad8565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102e261081e366004612e08565b611820565b34801561082f57600080fd5b506102e261083e366004612aa0565b611a67565b34801561084f57600080fd5b50600e546102ad90610100900460ff1681565b60006001600160e01b031982166380ac58cd60e01b148061089357506001600160e01b03198216635b5e139f60e01b145b806108ae57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6006546001600160a01b031633146108e75760405162461bcd60e51b81526004016108de90612f72565b60405180910390fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b606060008054610918906130e7565b80601f0160208091040260200160405190810160405280929190818152602001828054610944906130e7565b80156109915780601f1061096657610100808354040283529160200191610991565b820191906000526020600020905b81548152906001019060200180831161097457829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610a145760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108de565b506000908152600460205260409020546001600160a01b031690565b6000610a3b82610e59565b9050806001600160a01b0316836001600160a01b03161415610aa95760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108de565b336001600160a01b0382161480610ac55750610ac581336107e2565b610b375760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108de565b610b418383611aff565b505050565b6006546001600160a01b03163314610b705760405162461bcd60e51b81526004016108de90612f72565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b610b9c3382611b6d565b610bb85760405162461bcd60e51b81526004016108de90612fd7565b610b41838383611c64565b6006546001600160a01b03163314610bed5760405162461bcd60e51b81526004016108de90612f72565b6008546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610c26573d6000803e3d6000fd5b50565b610b4183838360405180602001604052806000815250611643565b333214610c635760405162461bcd60e51b81526004016108de90612fa7565b600e5460ff1615610cac5760405162461bcd60e51b815260206004820152601360248201527210d40e8810db185a5b5a5b99c81c185d5cd959606a1b60448201526064016108de565b6033815110610cfd5760405162461bcd60e51b815260206004820152601860248201527f43503a2041646f7074696f6e206c696d6974206973203530000000000000000060448201526064016108de565b6007546001600160a01b031660005b8251811015610b41576000838281518110610d3757634e487b7160e01b600052603260045260246000fd5b60200260200101519050336001600160a01b0316836001600160a01b0316636352211e836040518263ffffffff1660e01b8152600401610d7991815260200190565b602060405180830381600087803b158015610d9357600080fd5b505af1158015610da7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dcb9190612abc565b6001600160a01b0316148015610df657506000818152600260205260409020546001600160a01b0316155b15610e0557610e053382611e04565b5080610e1081613122565b915050610d0c565b6006546001600160a01b03163314610e425760405162461bcd60e51b81526004016108de90612f72565b8051610e5590600f906020840190612941565b5050565b6000818152600260205260408120546001600160a01b0316806108ae5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108de565b6006546001600160a01b03163314610efa5760405162461bcd60e51b81526004016108de90612f72565b600a54600b54600160115460ff166003811115610f2757634e487b7160e01b600052602160045260246000fd5b14610f745760405162461bcd60e51b815260206004820152601860248201527f43503a205265736572766564206d696e7420636c6f736564000000000000000060448201526064016108de565b60008111610fc45760405162461bcd60e51b815260206004820152601e60248201527f43503a204e6f206d6f72652072657365727665206d696e7473206c656674000060448201526064016108de565b60005b6014811015610ff757610fe53384610fde81613122565b9550611e04565b80610fef81613122565b915050610fc7565b50600a8290556110086014826130a4565b600b555050565b60006001600160a01b03821661107a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108de565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146110c05760405162461bcd60e51b81526004016108de90612f72565b6110ca6000611f46565b565b6006546001600160a01b031633146110f65760405162461bcd60e51b81526004016108de90612f72565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b031633146111425760405162461bcd60e51b81526004016108de90612f72565b600e54610100900460ff161561119a5760405162461bcd60e51b815260206004820152601960248201527f43503a204d65726b6c652074726565206973206c6f636b65640000000000000060448201526064016108de565b600c55565b6006546001600160a01b031633146111c95760405162461bcd60e51b81526004016108de90612f72565b600d55565b606060018054610918906130e7565b6006546001600160a01b031633146112075760405162461bcd60e51b81526004016108de90612f72565b600e805460ff1916911515919091179055565b6006546001600160a01b031633146112445760405162461bcd60e51b81526004016108de90612f72565b600e805461ff001916610100179055565b610e55338383611f98565b6006546001600160a01b0316331461128a5760405162461bcd60e51b81526004016108de90612f72565b614e1f81600a5461129b9190613059565b11156112e95760405162461bcd60e51b815260206004820152601a60248201527f43503a204d6f7265207469636b657473207468616e207065747300000000000060448201526064016108de565b60006112f761010083613071565b611302906001613059565b905060001960008267ffffffffffffffff81111561133057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611359578160200160208202803683370190505b50905060005b838110156113a5578282828151811061138857634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061139d81613122565b91505061135f565b5080516113b99060109060208401906129c5565b5050505050565b600a543332146113e25760405162461bcd60e51b81526004016108de90612fa7565b600260115460ff16600381111561140957634e487b7160e01b600052602160045260246000fd5b1461144e5760405162461bcd60e51b815260206004820152601560248201527410d40e88105b1b1bddc81b1a5cdd0818db1bdcd959605a1b60448201526064016108de565b600d5434146114965760405162461bcd60e51b815260206004820152601460248201527310d40e88125b9d985b1a5908115d1a081cd95b9d60621b60448201526064016108de565b6040516bffffffffffffffffffffffff193360601b1660208201526034810183905260009060540160405160208183030381529060405280519060200120905061151785858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600c549150849050612067565b6115635760405162461bcd60e51b815260206004820152601860248201527f43503a20496e76616c6964206d65726b6c652070726f6f66000000000000000060448201526064016108de565b61156c8361207d565b6115763383611e04565b50600101600a55505050565b6006546001600160a01b031633146115ac5760405162461bcd60e51b81526004016108de90612f72565b60038111156115f15760405162461bcd60e51b815260206004820152601160248201527043503a204f7574206f6620626f756e647360781b60448201526064016108de565b80600381111561161157634e487b7160e01b600052602160045260246000fd5b6011805460ff1916600183600381111561163b57634e487b7160e01b600052602160045260246000fd5b021790555050565b61164d3383611b6d565b6116695760405162461bcd60e51b81526004016108de90612fd7565b61167584848484612196565b50505050565b6000818152600260205260409020546060906001600160a01b03166116fa5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108de565b60006117046121c9565b90506000815111611724576040518060200160405280600081525061174f565b8061172e846121d8565b60405160200161173f929190612e79565b6040516020818303038152906040525b9392505050565b600f8054611763906130e7565b80601f016020809104026020016040519081016040528092919081815260200182805461178f906130e7565b80156117dc5780601f106117b1576101008083540402835291602001916117dc565b820191906000526020600020905b8154815290600101906020018083116117bf57829003601f168201915b505050505081565b6006546001600160a01b0316331461180e5760405162461bcd60e51b81526004016108de90612f72565b60009182526013602052604090912055565b600a543332146118425760405162461bcd60e51b81526004016108de90612fa7565b600360115460ff16600381111561186957634e487b7160e01b600052602160045260246000fd5b146118ab5760405162461bcd60e51b815260206004820152601260248201527110d40e88135a5b9d1a5b99c818db1bdcd95960721b60448201526064016108de565b614e1f81106118fc5760405162461bcd60e51b815260206004820152601e60248201527f43503a2045786365656473206d6178696d756d2050657420737570706c79000060448201526064016108de565b600d5434146119445760405162461bcd60e51b815260206004820152601460248201527310d40e88125b9d985b1a5908115d1a081cd95b9d60621b60448201526064016108de565b3360009081526012602052604090205460ff16156119a45760405162461bcd60e51b815260206004820152601c60248201527f43503a204164647265737320686173206d696e7465642061207065740000000060448201526064016108de565b33600081815260126020908152604091829020805460ff191660011790559051611a0f926119f392909187910160609290921b6bffffffffffffffffffffffff19168252601482015260340190565b60405160208183030381529060405280519060200120836122f2565b611a535760405162461bcd60e51b815260206004820152601560248201527443503a20496e76616c6964207369676e617475726560581b60448201526064016108de565b611a5d3382611e04565b600101600a555050565b6006546001600160a01b03163314611a915760405162461bcd60e51b81526004016108de90612f72565b6001600160a01b038116611af65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108de565b610c2681611f46565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611b3482610e59565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316611be65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108de565b6000611bf183610e59565b9050806001600160a01b0316846001600160a01b03161480611c2c5750836001600160a01b0316611c218461099b565b6001600160a01b0316145b80611c5c57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611c7782610e59565b6001600160a01b031614611cdf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108de565b6001600160a01b038216611d415760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108de565b611d4c600082611aff565b6001600160a01b0383166000908152600360205260408120805460019290611d759084906130a4565b90915550506001600160a01b0382166000908152600360205260408120805460019290611da3908490613059565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b038216611e5a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108de565b6000818152600260205260409020546001600160a01b031615611ebf5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108de565b6001600160a01b0382166000908152600360205260408120805460019290611ee8908490613059565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03161415611ffa5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108de565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60008261207485846123d1565b14949350505050565b60105461208c90610100613085565b81106120cf5760405162461bcd60e51b815260206004820152601260248201527110d40e88125b9d985b1a59081d1a58dad95d60721b60448201526064016108de565b6010805461010083049160009160ff851691908490811061210057634e487b7160e01b600052603260045260246000fd5b9060005260206000200154915060018183901c166001146121585760405162461bcd60e51b815260206004820152601260248201527110d40e88151a58dad95d0818db185a5b595960721b60448201526064016108de565b806001901b1982169150816010848154811061218457634e487b7160e01b600052603260045260246000fd5b60009182526020909120015550505050565b6121a1848484611c64565b6121ad8484848461248b565b6116755760405162461bcd60e51b81526004016108de90612f20565b6060600f8054610918906130e7565b6060816121fc5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612226578061221081613122565b915061221f9050600a83613071565b9150612200565b60008167ffffffffffffffff81111561224f57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612279576020820181803683370190505b5090505b8415611c5c5761228e6001836130a4565b915061229b600a8661313d565b6122a6906030613059565b60f81b8183815181106122c957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506122eb600a86613071565b945061227d565b6009546000906001600160a01b031661234d5760405162461bcd60e51b815260206004820152601a60248201527f43503a20496e76616c69642073797374656d206164647265737300000000000060448201526064016108de565b60006123a6846040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b6009549091506001600160a01b03166123bf8285612598565b6001600160a01b031614949350505050565b600081815b845181101561248357600085828151811061240157634e487b7160e01b600052603260045260246000fd5b60200260200101519050808311612443576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250612470565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061247b81613122565b9150506123d6565b509392505050565b60006001600160a01b0384163b1561258d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906124cf903390899088908890600401612ea8565b602060405180830381600087803b1580156124e957600080fd5b505af1925050508015612519575060408051601f3d908101601f1916820190925261251691810190612d85565b60015b612573573d808015612547576040519150601f19603f3d011682016040523d82523d6000602084013e61254c565b606091505b50805161256b5760405162461bcd60e51b81526004016108de90612f20565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c5c565b506001949350505050565b60008060006125a785856125b4565b9150915061248381612624565b6000808251604114156125eb5760208301516040840151606085015160001a6125df87828585612825565b9450945050505061261d565b825160401415612615576020830151604084015161260a868383612912565b93509350505061261d565b506000905060025b9250929050565b600081600481111561264657634e487b7160e01b600052602160045260246000fd5b141561264f5750565b600181600481111561267157634e487b7160e01b600052602160045260246000fd5b14156126bf5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016108de565b60028160048111156126e157634e487b7160e01b600052602160045260246000fd5b141561272f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016108de565b600381600481111561275157634e487b7160e01b600052602160045260246000fd5b14156127aa5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016108de565b60048160048111156127cc57634e487b7160e01b600052602160045260246000fd5b1415610c265760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016108de565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561285c5750600090506003612909565b8460ff16601b1415801561287457508460ff16601c14155b156128855750600090506004612909565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156128d9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661290257600060019250925050612909565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161293387828885612825565b935093505050935093915050565b82805461294d906130e7565b90600052602060002090601f01602090048101928261296f57600085556129b5565b82601f1061298857805160ff19168380011785556129b5565b828001600101855582156129b5579182015b828111156129b557825182559160200191906001019061299a565b506129c19291506129ff565b5090565b8280548282559060005260206000209081019282156129b557916020028201828111156129b557825182559160200191906001019061299a565b5b808211156129c15760008155600101612a00565b600067ffffffffffffffff831115612a2e57612a2e61317d565b612a41601f8401601f1916602001613028565b9050828152838383011115612a5557600080fd5b828260208301376000602084830101529392505050565b80358015158114612a7c57600080fd5b919050565b600082601f830112612a91578081fd5b61174f83833560208501612a14565b600060208284031215612ab1578081fd5b813561174f81613193565b600060208284031215612acd578081fd5b815161174f81613193565b60008060408385031215612aea578081fd5b8235612af581613193565b91506020830135612b0581613193565b809150509250929050565b600080600060608486031215612b24578081fd5b8335612b2f81613193565b92506020840135612b3f81613193565b929592945050506040919091013590565b60008060008060808587031215612b65578081fd5b8435612b7081613193565b93506020850135612b8081613193565b925060408501359150606085013567ffffffffffffffff811115612ba2578182fd5b612bae87828801612a81565b91505092959194509250565b60008060408385031215612bcc578182fd5b8235612bd781613193565b9150612be560208401612a6c565b90509250929050565b60008060408385031215612c00578182fd5b8235612c0b81613193565b946020939093013593505050565b600080600060408486031215612c2d578283fd5b833567ffffffffffffffff80821115612c44578485fd5b818601915086601f830112612c57578485fd5b813581811115612c65578586fd5b8760208260051b8501011115612c79578586fd5b6020928301989097509590910135949350505050565b60006020808385031215612ca1578182fd5b823567ffffffffffffffff80821115612cb8578384fd5b818501915085601f830112612ccb578384fd5b813581811115612cdd57612cdd61317d565b8060051b9150612cee848301613028565b8181528481019084860184860187018a1015612d08578788fd5b8795505b83861015612d2a578035835260019590950194918601918601612d0c565b5098975050505050505050565b600060208284031215612d48578081fd5b61174f82612a6c565b600060208284031215612d62578081fd5b5035919050565b600060208284031215612d7a578081fd5b813561174f816131a8565b600060208284031215612d96578081fd5b815161174f816131a8565b600060208284031215612db2578081fd5b813567ffffffffffffffff811115612dc8578182fd5b8201601f81018413612dd8578182fd5b611c5c84823560208401612a14565b60008060408385031215612df9578182fd5b50508035926020909101359150565b60008060408385031215612e1a578182fd5b82359150602083013567ffffffffffffffff811115612e37578182fd5b612e4385828601612a81565b9150509250929050565b60008151808452612e658160208601602086016130bb565b601f01601f19169290920160200192915050565b60008351612e8b8184602088016130bb565b835190830190612e9f8183602088016130bb565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612edb90830184612e4d565b9695505050505050565b6020810160048310612f0757634e487b7160e01b600052602160045260246000fd5b91905290565b60208152600061174f6020830184612e4d565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526016908201527543503a205765206c696b65207265616c20757365727360501b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156130515761305161317d565b604052919050565b6000821982111561306c5761306c613151565b500190565b60008261308057613080613167565b500490565b600081600019048311821515161561309f5761309f613151565b500290565b6000828210156130b6576130b6613151565b500390565b60005b838110156130d65781810151838201526020016130be565b838111156116755750506000910152565b600181811c908216806130fb57607f821691505b6020821081141561311c57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561313657613136613151565b5060010190565b60008261314c5761314c613167565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610c2657600080fd5b6001600160e01b031981168114610c2657600080fdfea26469706673582212208f09dd9b7a34c470c9bf321db68d0463b4606a0ff50b711e344eabf8e07a049764736f6c63430008040033
[ 5, 7, 12 ]
0xf3D166d8A0db4D40e66552a5c228B1e46571acBB
pragma solidity ^0.4.20; contract owned { address public owner; event Log(string s); constructor() public payable{ owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } function isOwner()public{ if(msg.sender==owner)emit Log("Owner"); else{ emit Log("Not Owner"); } } } contract ERC20 is owned{ string public name; string public symbol; uint256 public totalSupply; uint8 public constant decimals = 4; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); constructor(uint256 _totalSupply,string tokenName,string tokenSymbol) public { symbol = tokenSymbol; name = tokenName; totalSupply = _totalSupply; balances[owner] = totalSupply; emit Transfer(address(0), owner, totalSupply); } function totalSupply() public view returns (uint){ return totalSupply; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender ]- tokens; balances[to] = 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] = balances[from] - tokens; allowed[from][msg.sender] = allowed[from][msg.sender] - (tokens); balances[to] = balances[to]+(tokens); emit Transfer(from, 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 allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } } contract EPLAY is ERC20 { uint256 activeUsers; mapping(address => bool) isRegistered; mapping(address => uint256) accountID; mapping(uint256 => address) accountFromID; mapping(address => bool) isTrusted; event Burn(address _from,uint256 _value); modifier isTrustedContract{ require(isTrusted[msg.sender]); _; } modifier registered{ require(isRegistered[msg.sender]); _; } constructor( string tokenName, string tokenSymbol) public payable ERC20(74145513585,tokenName,tokenSymbol) { } function distribute(address[] users,uint256[] balances) public onlyOwner { uint i; for(i = 0;i <users.length;i++){ transferFrom(owner,users[i],balances[i]); } } function burnFrom(address _from, uint256 _value) internal returns (bool success) { require(balances[_from] >= _value); balances[_from] -= _value; totalSupply -= _value; emit Burn(_from, _value); return true; } function contractBurn(address _for,uint256 value)external isTrustedContract{ burnFrom(_for,value); } function burn(uint256 val)public{ burnFrom(msg.sender,val); } function registerAccount(address user)internal{ if(!isRegistered[user]){ isRegistered[user] = true; activeUsers += 1; accountID[user] = activeUsers; accountFromID[activeUsers] = user; } } function registerExternal()external{ registerAccount(msg.sender); } function register() public { registerAccount(msg.sender); } function testConnection() external { emit Log("CONNECTED"); } }
0x6080604052600436106100fc576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610101578063095ea7b31461019157806318160ddd146101f65780631aa3a0081461022157806323b872dd146102385780632929abe6146102bd578063313ce567146103665780633412a15c1461039757806339b22120146103ae57806342966c68146103fb57806370a08231146104285780638da5cb5b1461047f5780638f32d59b146104d657806395d89b41146104ed578063a9059cbb1461057d578063c42b5fe1146105e2578063dd62ed3e146105f9578063f2fde38b14610670575b600080fd5b34801561010d57600080fd5b506101166106b3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561015657808201518184015260208101905061013b565b50505050905090810190601f1680156101835780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561019d57600080fd5b506101dc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610751565b604051808215151515815260200191505060405180910390f35b34801561020257600080fd5b5061020b610843565b6040518082815260200191505060405180910390f35b34801561022d57600080fd5b5061023661084d565b005b34801561024457600080fd5b506102a3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610858565b604051808215151515815260200191505060405180910390f35b3480156102c957600080fd5b506103646004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290505050610ad3565b005b34801561037257600080fd5b5061037b610bab565b604051808260ff1660ff16815260200191505060405180910390f35b3480156103a357600080fd5b506103ac610bb0565b005b3480156103ba57600080fd5b506103f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c1a565b005b34801561040757600080fd5b5061042660048036038101908080359060200190929190505050610c81565b005b34801561043457600080fd5b50610469600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c8f565b6040518082815260200191505060405180910390f35b34801561048b57600080fd5b50610494610cd8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104e257600080fd5b506104eb610cfd565b005b3480156104f957600080fd5b50610502610e2a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610542578082015181840152602081019050610527565b50505050905090810190601f16801561056f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561058957600080fd5b506105c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ec8565b604051808215151515815260200191505060405180910390f35b3480156105ee57600080fd5b506105f7611043565b005b34801561060557600080fd5b5061065a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061104e565b6040518082815260200191505060405180910390f35b34801561067c57600080fd5b506106b1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506110d5565b005b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107495780601f1061071e57610100808354040283529160200191610749565b820191906000526020600020905b81548152906001019060200180831161072c57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b61085633611173565b565b600081600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b3057600080fd5b600090505b8251811015610ba657610b986000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff168483815181101515610b7157fe5b906020019060200201518484815181101515610b8957fe5b90602001906020020151610858565b508080600101915050610b35565b505050565b600481565b7fcf34ef537ac33ee1ac626ca1587a0a7e8e51561e5514f8cb36afa1c5102b3bab6040518080602001828103825260098152602001807f434f4e4e4543544544000000000000000000000000000000000000000000000081525060200191505060405180910390a1565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610c7257600080fd5b610c7c82826112cd565b505050565b610c8b33826112cd565b5050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610dbf577fcf34ef537ac33ee1ac626ca1587a0a7e8e51561e5514f8cb36afa1c5102b3bab6040518080602001828103825260058152602001807f4f776e657200000000000000000000000000000000000000000000000000000081525060200191505060405180910390a1610e28565b7fcf34ef537ac33ee1ac626ca1587a0a7e8e51561e5514f8cb36afa1c5102b3bab6040518080602001828103825260098152602001807f4e6f74204f776e6572000000000000000000000000000000000000000000000081525060200191505060405180910390a15b565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ec05780601f10610e9557610100808354040283529160200191610ec0565b820191906000526020600020905b815481529060010190602001808311610ea357829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205403600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b61104c33611173565b565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561113057600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600760008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156112ca576001600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600660008282540192505081905550600654600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508060096000600654815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b600081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561131d57600080fd5b81600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816003600082825403925050819055507fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58383604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a160019050929150505600a165627a7a7230582047cce0ae2c3360ed68f7f60830a650089f3c3baff24b60be062aedecd212a9de0029
[ 0, 2 ]
0xf3d2d352ad2296eae4b2303c560547a47bc6fafc
// 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; } } /** * @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 internal _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); } } /* The MIT License (MIT) Copyright (c) 2018 Murray Software, LLC. 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 max-line-length //solhint-disable no-inline-assembly contract CloneFactory { function createClone(address target) internal virtual returns (address result) { bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone, 0x14), targetBytes) mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) result := create(0, clone, 0x37) } } function isClone(address target, address query) internal view virtual returns (bool result) { bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000) mstore(add(clone, 0xa), targetBytes) mstore(add(clone, 0x1e), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) let other := add(clone, 0x40) extcodecopy(query, other, 0, 0x2d) result := and( eq(mload(clone), mload(other)), eq(mload(add(clone, 0xd)), mload(add(other, 0xd))) ) } } } interface IEaselyContractInitializer { function init(bool[8] memory bools, address[8] memory addresses, uint256[32] memory uints, string[8] memory strings) external; } contract EaselyContractFactory is CloneFactory, Ownable { mapping(address => bool) private approverStatus; mapping(address => bool) private approvedImplementations; address[] private contracts; event ContractCreated(address creator, address contractAddress, address implementation, string easelyIdentifier); constructor(address[] memory implementations) { approverStatus[_msgSender()] = true; for (uint256 i = 0; i < implementations.length; i++) { approvedImplementations[implementations[i]] = true; } } function addApprover(address approver) external onlyOwner { approverStatus[approver] = true; } function removeApprover(address approver) external onlyOwner { approverStatus[approver] = false; } function approveImplementation(address implementation_) external { require(approverStatus[_msgSender()], "Must have approver status to approve a new implementation"); approvedImplementations[implementation_] = true; } function removeImplementation(address implementation_) external { require(approverStatus[_msgSender()], "Must have approver status to remove an implementation"); approvedImplementations[implementation_] = false; } function createContract( address implementation_, string memory easelyIdentifier, bool[8] memory bools, address[8] memory addresses, uint256[32] memory uints, string[8] memory strings ) external { require(approvedImplementations[implementation_], "This is not an approved implementation"); addresses[0] = _msgSender(); address cloneAddr = createClone(implementation_); IEaselyContractInitializer newContract = IEaselyContractInitializer(cloneAddr); newContract.init(bools, addresses, uints, strings); contracts.push(cloneAddr); emit ContractCreated(msg.sender, cloneAddr, implementation_, easelyIdentifier); } function isApproved(address address_) external view returns (bool) { return approvedImplementations[address_]; } function getContractAddress(uint256 index) external view returns (address) { return contracts[index]; } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b14610127578063aefa7d981461014c578063b646c1941461015f578063f2fde38b14610172578063f7fa10431461018557600080fd5b80631b10b81f146100a357806322175a32146100b8578063673448dd146100cb5780636cf4c88f1461010c578063715018a61461011f575b600080fd5b6100b66100b136600461099c565b610198565b005b6100b66100c636600461097a565b61031e565b6100f76100d936600461097a565b6001600160a01b031660009081526002602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100b661011a36600461097a565b6103c4565b6100b661043f565b6000546001600160a01b03165b6040516001600160a01b039091168152602001610103565b61013461015a366004610a9c565b6104a5565b6100b661016d36600461097a565b6104d5565b6100b661018036600461097a565b610556565b6100b661019336600461097a565b610621565b6001600160a01b03861660009081526002602052604090205460ff166102145760405162461bcd60e51b815260206004820152602660248201527f54686973206973206e6f7420616e20617070726f76656420696d706c656d656e6044820152653a30ba34b7b760d11b60648201526084015b60405180910390fd5b3383526000610222876106ca565b6040516364100bb360e01b815290915081906001600160a01b038216906364100bb390610259908990899089908990600401610ba8565b600060405180830381600087803b15801561027357600080fd5b505af1158015610287573d6000803e3d6000fd5b5050600380546001810182556000919091527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0180546001600160a01b0319166001600160a01b03861617905550506040517f1a0648a058da7b232206ab52c0f5388881e98d2f281dd6435b14234f21bcc64f9061030c90339085908c908c90610b6a565b60405180910390a15050505050505050565b3360009081526001602052604090205460ff166103a35760405162461bcd60e51b815260206004820152603560248201527f4d757374206861766520617070726f7665722073746174757320746f2072656d60448201527f6f766520616e20696d706c656d656e746174696f6e0000000000000000000000606482015260840161020b565b6001600160a01b03166000908152600260205260409020805460ff19169055565b6000546001600160a01b0316331461041e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161020b565b6001600160a01b03166000908152600160205260409020805460ff19169055565b6000546001600160a01b031633146104995760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161020b565b6104a36000610725565b565b6000600382815481106104ba576104ba610c5f565b6000918252602090912001546001600160a01b031692915050565b6000546001600160a01b0316331461052f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161020b565b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b6000546001600160a01b031633146105b05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161020b565b6001600160a01b0381166106155760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161020b565b61061e81610725565b50565b3360009081526001602052604090205460ff166106a65760405162461bcd60e51b815260206004820152603960248201527f4d757374206861766520617070726f7665722073746174757320746f2061707060448201527f726f76652061206e657720696d706c656d656e746174696f6e00000000000000606482015260840161020b565b6001600160a01b03166000908152600260205260409020805460ff19166001179055565b6000808260601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f0949350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461078c57600080fd5b919050565b600082601f8301126107a257600080fd5b6107aa610c35565b808385610100860111156107bd57600080fd5b60005b60088110156107e7576107d282610775565b845260209384019391909101906001016107c0565b509095945050505050565b600082601f83011261080357600080fd5b61080b610c35565b8083856101008601111561081e57600080fd5b6000805b600881101561086357823567ffffffffffffffff811115610841578283fd5b61084d89828a016108ed565b8652506020948501949290920191600101610822565b50919695505050505050565b600082601f83011261088057600080fd5b60405161040080820182811067ffffffffffffffff821117156108a5576108a5610c75565b60405281848281018710156108b957600080fd5b600092505b60208084106108cd57506108e2565b813583526001939093019291820191016108be565b509195945050505050565b600082601f8301126108fe57600080fd5b813567ffffffffffffffff8082111561091957610919610c75565b604051601f8301601f19908116603f0116810190828211818310171561094157610941610c75565b8160405283815286602085880101111561095a57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561098c57600080fd5b61099582610775565b9392505050565b60008060008060008061066087890312156109b657600080fd5b6109bf87610775565b955060208088013567ffffffffffffffff808211156109dd57600080fd5b6109e98b838c016108ed565b97508a605f8b01126109fa57600080fd5b610a02610c35565b91508160408b016101408c018d811115610a1b57600080fd5b60005b6008811015610a495782358015158114610a3757600080fd5b86529486019491860191600101610a1e565b50829950610a578e82610791565b9850505050610a6a8b6102408c0161086f565b94506106408a0135925080831115610a8157600080fd5b5050610a8f89828a016107f2565b9150509295509295509295565b600060208284031215610aae57600080fd5b5035919050565b60008261010081018360005b60088110156107e7578383038752610ada838351610b1d565b6020978801979093509190910190600101610ac1565b8060005b6020808210610b035750610b17565b825185529384019390910190600101610af4565b50505050565b6000815180845260005b81811015610b4357602081850181015186830182015201610b27565b81811115610b55576000602083870101525b50601f01601f19169290920160200192915050565b60006001600160a01b038087168352808616602084015280851660408401525060806060830152610b9e6080830184610b1d565b9695505050505050565b60006106208287835b6008811015610bd25781511515835260209283019290910190600101610bb1565b50505061010083018660005b6008811015610c065781516001600160a01b0316835260209283019290910190600101610bde565b505050610c17610200840186610af0565b80610600840152610c2a81840185610ab5565b979650505050505050565b604051610100810167ffffffffffffffff81118282101715610c5957610c59610c75565b60405290565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212209824851ee8ad210921420afd07b9b18786daf601b311db2ad4d68ceeef0b9d0b64736f6c63430008070033
[ 38 ]
0xf3d2f593ef2b17d42cc568af437406a4a789fb1a
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Test Contract /// @author: manifold.xyz import "./ERC1155Creator.sol"; ///////////////////////////////// // // // // // PANDAMAN_NFT_CONTRACT // // // // // ///////////////////////////////// contract TEST is ERC1155Creator { constructor() ERC1155Creator() {} } // 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 ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122048d50270782a55c5d7b5575308f417304ea91cc4835196713842d1f2e8713aaf64736f6c63430008070033
[ 5 ]
0xf3d3091B994Ce6b5aD4a6efAd9425749a2062608
// 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 ]
0xF3d39A7FEbA9bE0C1D18b355E7eD01070Ee2c561
// SPDX-License-Identifier: AGPLv3 pragma solidity 0.8.4; import "@openzeppelin/contracts/access/Ownable.sol"; import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; interface IVestable { function vest( bool vest, address _receiver, uint256 _amount ) external; } contract AirDrop is Ownable { struct DropInfo { bytes32 root; uint128 total; uint128 remaining; bool vest; } mapping(uint256 => DropInfo) public drops; uint256 public tranches; mapping(uint256 => mapping(address => bool)) private claimed; IVestable public vesting; event LogNewDrop(uint256 trancheId, bytes32 merkleRoot, uint128 totalAmount); event LogClaim(address indexed account, bool vest, uint256 trancheId, uint128 amount); event LogExpireDrop(uint256 trancheId, bytes32 merkleRoot, uint128 totalAmount, uint128 remaining); function setVesting(address _vesting) public onlyOwner { vesting = IVestable(_vesting); } function newDrop( bytes32 merkleRoot, uint128 totalAmount, bool vest ) external onlyOwner returns (uint256 trancheId) { trancheId = tranches; DropInfo memory di = DropInfo(merkleRoot, totalAmount, totalAmount, vest); drops[trancheId] = di; tranches += 1; emit LogNewDrop(trancheId, merkleRoot, totalAmount); } function expireDrop(uint256 trancheId) external onlyOwner { require(trancheId < tranches, "expireDrop: !trancheId"); DropInfo memory di = drops[trancheId]; delete drops[trancheId]; emit LogExpireDrop(trancheId, di.root, di.total, di.remaining); } function isClaimed(uint256 trancheId, address account) public view returns (bool) { return claimed[trancheId][account]; } function claim( bool vest, uint256 trancheId, uint128 amount, bytes32[] calldata merkleProof ) external { require(trancheId < tranches, "claim: !trancheId"); require(!isClaimed(trancheId, msg.sender), "claim: Drop already claimed"); DropInfo storage di = drops[trancheId]; bytes32 root = di.root; require(root != 0, "claim: Drop expired"); uint128 remaining = di.remaining; require(amount <= remaining, "claim: Not enough remaining"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(msg.sender, amount)); require(MerkleProof.verify(merkleProof, root, node), "claim: Invalid proof"); // Mark it claimed and send the token. claimed[trancheId][msg.sender] = true; di.remaining = remaining - amount; if (di.vest) { vest = true; } vesting.vest(vest, msg.sender, amount); emit LogClaim(msg.sender, vest, trancheId, amount); } function verifyDrop( uint256 trancheId, uint128 amount, bytes32[] calldata merkleProof ) external view returns (bool) { require(trancheId < tranches, "verifyDrop: !trancheId"); require(!isClaimed(trancheId, msg.sender), "verifyDrop: Drop already claimed"); DropInfo storage di = drops[trancheId]; bytes32 root = di.root; require(root != 0, "verifyDrop: Drop expired"); require(amount <= di.remaining, "verifyDrop: Not enough remaining"); // Verify the merkle proof. bytes32 node = keccak256(abi.encodePacked(msg.sender, amount)); return MerkleProof.verify(merkleProof, root, node); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c80638da5cb5b116100715780638da5cb5b146101b2578063c3c6a7e4146101c3578063d2ef0795146101e6578063ebf04917146101f9578063f2fde38b14610202578063f9ae49d71461021557600080fd5b80631688cf31146100b957806344c63eec146100df5780635eb399681461010a5780636f6ff3bc14610182578063715018a614610197578063789b03841461019f575b600080fd5b6100cc6100c7366004610d04565b610228565b6040519081526020015b60405180910390f35b6004546100f2906001600160a01b031681565b6040516001600160a01b0390911681526020016100d6565b610150610118366004610d3f565b60016020819052600091825260409091208054918101546002909101546001600160801b0380831692600160801b9004169060ff1684565b6040516100d694939291909384526001600160801b039283166020850152911660408301521515606082015260800190565b610195610190366004610c76565b61033a565b005b610195610386565b6101956101ad366004610d3f565b6103bc565b6000546001600160a01b03166100f2565b6101d66101d1366004610d82565b610501565b60405190151581526020016100d6565b6101d66101f4366004610d57565b6106e2565b6100cc60025481565b610195610210366004610c76565b61070d565b610195610223366004610c97565b6107a8565b600080546001600160a01b0316331461025c5760405162461bcd60e51b815260040161025390610e12565b60405180910390fd5b5060028054604080516080810182528681526001600160801b03808716602080840182815284860192835288151560608601908152600088815260019384905296872086518155915193518516600160801b029390941692909217828201559151908601805491151560ff199092169190911790558454939491939092906102e5908490610e47565b909155505060408051838152602081018790526001600160801b0386168183015290517f543d1e01957f2095e777b83ae97469347501afcb4b226d5bc4316c4a7b76a1159181900360600190a1509392505050565b6000546001600160a01b031633146103645760405162461bcd60e51b815260040161025390610e12565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146103b05760405162461bcd60e51b815260040161025390610e12565b6103ba6000610adc565b565b6000546001600160a01b031633146103e65760405162461bcd60e51b815260040161025390610e12565b60025481106104305760405162461bcd60e51b8152602060048201526016602482015275195e1c1a5c99511c9bdc0e88085d1c985b98da19525960521b6044820152606401610253565b600081815260016020818152604080842081516080810183528154815281850180546001600160801b03808216848801908152600160801b9092041683860190815260028501805460ff8116151560608701528b8b52989097529388905596905560ff19909416909255825193519151905192937f4f5825f2cb6e87df3f32b1b482c0e97d787ea496ab20fe503438b96bdbe8c8b9936104f5938793909193845260208401929092526001600160801b03908116604084015216606082015260800190565b60405180910390a15050565b6000600254851061054d5760405162461bcd60e51b81526020600482015260166024820152751d995c9a599e511c9bdc0e88085d1c985b98da19525960521b6044820152606401610253565b61055785336106e2565b156105a45760405162461bcd60e51b815260206004820181905260248201527f76657269667944726f703a2044726f7020616c726561647920636c61696d65646044820152606401610253565b60008581526001602052604090208054806106015760405162461bcd60e51b815260206004820152601860248201527f76657269667944726f703a2044726f70206578706972656400000000000000006044820152606401610253565b60018201546001600160801b03600160801b909104811690871611156106695760405162461bcd60e51b815260206004820181905260248201527f76657269667944726f703a204e6f7420656e6f7567682072656d61696e696e676044820152606401610253565b6000338760405160200161067e929190610dda565b6040516020818303038152906040528051906020012090506106d6868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250869250859150610b2c9050565b98975050505050505050565b60009182526003602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000546001600160a01b031633146107375760405162461bcd60e51b815260040161025390610e12565b6001600160a01b03811661079c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610253565b6107a581610adc565b50565b60025484106107ed5760405162461bcd60e51b815260206004820152601160248201527018db185a5b4e88085d1c985b98da195259607a1b6044820152606401610253565b6107f784336106e2565b156108445760405162461bcd60e51b815260206004820152601b60248201527f636c61696d3a2044726f7020616c726561647920636c61696d656400000000006044820152606401610253565b60008481526001602052604090208054806108975760405162461bcd60e51b815260206004820152601360248201527218db185a5b4e88111c9bdc08195e1c1a5c9959606a1b6044820152606401610253565b60018201546001600160801b03600160801b90910481169086168110156109005760405162461bcd60e51b815260206004820152601b60248201527f636c61696d3a204e6f7420656e6f7567682072656d61696e696e6700000000006044820152606401610253565b60003387604051602001610915929190610dda565b60405160208183030381529060405280519060200120905061096d868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250879250859150610b2c9050565b6109b05760405162461bcd60e51b815260206004820152601460248201527331b630b4b69d1024b73b30b634b210383937b7b360611b6044820152606401610253565b60008881526003602090815260408083203384529091529020805460ff191660011790556109de8783610e5f565b6001850180546001600160801b03928316600160801b029216919091179055600284015460ff1615610a0f57600198505b60048054604051635ef09f2760e01b81528b1515928101929092523360248301526001600160801b03891660448301526001600160a01b031690635ef09f2790606401600060405180830381600087803b158015610a6c57600080fd5b505af1158015610a80573d6000803e3d6000fd5b5050604080518c15158152602081018c90526001600160801b038b168183015290513393507f1075f04194da38066e5eab33031661d8e457c1d631927369c4131bd07b32f3da92509081900360600190a2505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600081815b8551811015610bde576000868281518110610b5c57634e487b7160e01b600052603260045260246000fd5b60200260200101519050808311610b9e576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250610bcb565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080610bd681610e87565b915050610b31565b509092149392505050565b80356001600160a01b0381168114610c0057600080fd5b919050565b60008083601f840112610c16578182fd5b50813567ffffffffffffffff811115610c2d578182fd5b6020830191508360208260051b8501011115610c4857600080fd5b9250929050565b80358015158114610c0057600080fd5b80356001600160801b0381168114610c0057600080fd5b600060208284031215610c87578081fd5b610c9082610be9565b9392505050565b600080600080600060808688031215610cae578081fd5b610cb786610c4f565b945060208601359350610ccc60408701610c5f565b9250606086013567ffffffffffffffff811115610ce7578182fd5b610cf388828901610c05565b969995985093965092949392505050565b600080600060608486031215610d18578283fd5b83359250610d2860208501610c5f565b9150610d3660408501610c4f565b90509250925092565b600060208284031215610d50578081fd5b5035919050565b60008060408385031215610d69578182fd5b82359150610d7960208401610be9565b90509250929050565b60008060008060608587031215610d97578384fd5b84359350610da760208601610c5f565b9250604085013567ffffffffffffffff811115610dc2578283fd5b610dce87828801610c05565b95989497509550505050565b60609290921b6bffffffffffffffffffffffff1916825260801b6fffffffffffffffffffffffffffffffff1916601482015260240190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610e5a57610e5a610ea2565b500190565b60006001600160801b0383811690831681811015610e7f57610e7f610ea2565b039392505050565b6000600019821415610e9b57610e9b610ea2565b5060010190565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220e048cd0da016a060216969aff2734a2c6a492356b407d03b17e29456c76caadd64736f6c63430008040033
[ 38 ]
0xf3d44f2fb162ad12aae1d4b4b7d463927ee96c5c
// Sources flattened with hardhat v2.3.0 https://hardhat.org 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 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 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; /** * @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); } 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; /** * @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; } pragma solidity ^0.8.0; interface IERC1155Supply { /** * @dev Total amount of tokens in with a given id. */ function totalSupply(uint256 id) external view returns (uint256); /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) external view returns (bool); } // File contracts/IarteQTokens.sol pragma solidity ^0.8.0; /// @author Kam Amini <kam@2b.team> <kam.cpp@gmail.com> /// /// @title An interface which allows ERC-20 tokens to interact with the /// main ERC-1155 contract /// /// @notice Use at your own risk interface IarteQTokens { function compatBalanceOf(address origin, address account, uint256 tokenId) external view returns (uint256); function compatTotalSupply(address origin, uint256 tokenId) external view returns (uint256); function compatTransfer(address origin, address to, uint256 tokenId, uint256 amount) external; function compatTransferFrom(address origin, address from, address to, uint256 tokenId, uint256 amount) external; function compatAllowance(address origin, address account, address operator) external view returns (uint256); function compatApprove(address origin, address operator, uint256 amount) external; } // File contracts/ARTEQ.sol // // Copyright (C) 2021 BillionBuild (2B) Team. Reproduction in whole or in part // without written permission is prohibited. All rights reserved. // // SPDX-License-Identifier: GNU General Public License v3.0 pragma solidity ^0.8.0; /// @author Kam Amini <kam@2b.team> <kam.cpp@gmail.com> /// /// @title ARTEQ token; the main asset in artèQ Investment Fund ecosystem /// /// @notice Use at your own risk contract ARTEQ is Context, ERC165, IERC20Metadata { uint256 public constant ARTEQTokenId = 1; address private _adminAccount; address private _arteQTokensContract; modifier onlyAdmin() { require(_msgSender() == _adminAccount, "ARTEQ: must be admin"); _; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) { return interfaceId == type(IERC20).interfaceId || interfaceId == type(IERC20Metadata).interfaceId || super.supportsInterface(interfaceId); } constructor(address arteQTokensContract) { _adminAccount = _msgSender(); _arteQTokensContract = arteQTokensContract; } function name() public view virtual override returns (string memory) { return "arteQ Investment Fund Token"; } function symbol() public view virtual override returns (string memory) { return "ARTEQ"; } function decimals() public view virtual override returns (uint8) { return 0; } function totalSupply() public view virtual override returns (uint256) { return IarteQTokens(_arteQTokensContract).compatTotalSupply(_msgSender(), ARTEQTokenId); } function balanceOf(address account) public view virtual override returns (uint256) { return IarteQTokens(_arteQTokensContract).compatBalanceOf(_msgSender(), account, ARTEQTokenId); } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { IarteQTokens(_arteQTokensContract).compatTransfer(_msgSender(), recipient, ARTEQTokenId, amount); emit Transfer(_msgSender(), recipient, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { IarteQTokens(_arteQTokensContract).compatTransferFrom(_msgSender(), sender, recipient, ARTEQTokenId, amount); emit Transfer(sender, recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return IarteQTokens(_arteQTokensContract).compatAllowance(_msgSender(), owner, spender); } function approve(address spender, uint256 amount) public virtual override returns (bool) { IarteQTokens(_arteQTokensContract).compatApprove(_msgSender(), spender, amount); emit Approval(_msgSender(), spender, amount); return true; } // If this contract gets a balance in some ERC20 contract after it's finished, then we can rescue it. function rescueTokens(IERC20 foreignToken, address to) external onlyAdmin { foreignToken.transfer(to, foreignToken.balanceOf(address(this))); } // If this contract gets a balance in some ERC721 contract after it's finished, then we can rescue it. function approveNFTRescue(IERC721 foreignNFT, address to) external onlyAdmin { foreignNFT.setApprovalForAll(to, true); } receive() external payable { revert("ARTEQ: cannot accept ether"); } fallback() external payable { revert("ARTEQ: cannot accept ether"); } }
0x6080604052600436106100c65760003560e01c80633af48da81161007f578063857f10d511610059578063857f10d51461030a57806395d89b4114610333578063a9059cbb1461035e578063dd62ed3e1461039b57610106565b80633af48da8146102795780635431c94e146102a457806370a08231146102cd57610106565b806301ffc9a71461014157806306fdde031461017e578063095ea7b3146101a957806318160ddd146101e657806323b872dd14610211578063313ce5671461024e57610106565b36610106576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100fd906112ef565b60405180910390fd5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610138906112ef565b60405180910390fd5b34801561014d57600080fd5b5061016860048036038101906101639190610f80565b6103d8565b60405161017591906112b2565b60405180910390f35b34801561018a57600080fd5b506101936104ba565b6040516101a091906112cd565b60405180910390f35b3480156101b557600080fd5b506101d060048036038101906101cb9190610f1b565b6104f7565b6040516101dd91906112b2565b60405180910390f35b3480156101f257600080fd5b506101fb610607565b604051610208919061132f565b60405180910390f35b34801561021d57600080fd5b5061023860048036038101906102339190610ecc565b6106c3565b60405161024591906112b2565b60405180910390f35b34801561025a57600080fd5b506102636107d2565b604051610270919061134a565b60405180910390f35b34801561028557600080fd5b5061028e6107d7565b60405161029b919061132f565b60405180910390f35b3480156102b057600080fd5b506102cb60048036038101906102c69190610fa9565b6107dc565b005b3480156102d957600080fd5b506102f460048036038101906102ef9190610e67565b61098b565b604051610301919061132f565b60405180910390f35b34801561031657600080fd5b50610331600480360381019061032c9190610fe5565b610a4b565b005b34801561033f57600080fd5b50610348610b52565b60405161035591906112cd565b60405180910390f35b34801561036a57600080fd5b5061038560048036038101906103809190610f1b565b610b8f565b60405161039291906112b2565b60405180910390f35b3480156103a757600080fd5b506103c260048036038101906103bd9190610e90565b610ca2565b6040516103cf919061132f565b60405180910390f35b60007f36372b07000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104a357507fa219a025000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806104b357506104b282610d62565b5b9050919050565b60606040518060400160405280601b81526020017f617274655120496e766573746d656e742046756e6420546f6b656e0000000000815250905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634ec8d97361053f610dcc565b85856040518463ffffffff1660e01b815260040161055f939291906111e4565b600060405180830381600087803b15801561057957600080fd5b505af115801561058d573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff166105b0610dcc565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516105f5919061132f565b60405180910390a36001905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c80c3ae661064f610dcc565b60016040518363ffffffff1660e01b815260040161066e929190611289565b60206040518083038186803b15801561068657600080fd5b505afa15801561069a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106be9190611021565b905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631d1a2b6461070b610dcc565b86866001876040518663ffffffff1660e01b8152600401610730959493929190611191565b600060405180830381600087803b15801561074a57600080fd5b505af115801561075e573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516107bf919061132f565b60405180910390a3600190509392505050565b600090565b600181565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661081b610dcc565b73ffffffffffffffffffffffffffffffffffffffff1614610871576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108689061130f565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb828473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016108c7919061113f565b60206040518083038186803b1580156108df57600080fd5b505afa1580156108f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109179190611021565b6040518363ffffffff1660e01b8152600401610934929190611289565b602060405180830381600087803b15801561094e57600080fd5b505af1158015610962573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109869190610f57565b505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630dc7e8da6109d3610dcc565b8460016040518463ffffffff1660e01b81526004016109f4939291906111e4565b60206040518083038186803b158015610a0c57600080fd5b505afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190611021565b9050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610a8a610dcc565b73ffffffffffffffffffffffffffffffffffffffff1614610ae0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad79061130f565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a22cb4658260016040518363ffffffff1660e01b8152600401610b1c929190611260565b600060405180830381600087803b158015610b3657600080fd5b505af1158015610b4a573d6000803e3d6000fd5b505050505050565b60606040518060400160405280600581526020017f4152544551000000000000000000000000000000000000000000000000000000815250905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d07d425d610bd7610dcc565b856001866040518563ffffffff1660e01b8152600401610bfa949392919061121b565b600060405180830381600087803b158015610c1457600080fd5b505af1158015610c28573d6000803e3d6000fd5b505050508273ffffffffffffffffffffffffffffffffffffffff16610c4b610dcc565b73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c90919061132f565b60405180910390a36001905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663b664ab25610cea610dcc565b85856040518463ffffffff1660e01b8152600401610d0a9392919061115a565b60206040518083038186803b158015610d2257600080fd5b505afa158015610d36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5a9190611021565b905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b600081359050610de38161146a565b92915050565b600081519050610df881611481565b92915050565b600081359050610e0d81611498565b92915050565b600081359050610e22816114af565b92915050565b600081359050610e37816114c6565b92915050565b600081359050610e4c816114dd565b92915050565b600081519050610e61816114dd565b92915050565b600060208284031215610e7957600080fd5b6000610e8784828501610dd4565b91505092915050565b60008060408385031215610ea357600080fd5b6000610eb185828601610dd4565b9250506020610ec285828601610dd4565b9150509250929050565b600080600060608486031215610ee157600080fd5b6000610eef86828701610dd4565b9350506020610f0086828701610dd4565b9250506040610f1186828701610e3d565b9150509250925092565b60008060408385031215610f2e57600080fd5b6000610f3c85828601610dd4565b9250506020610f4d85828601610e3d565b9150509250929050565b600060208284031215610f6957600080fd5b6000610f7784828501610de9565b91505092915050565b600060208284031215610f9257600080fd5b6000610fa084828501610dfe565b91505092915050565b60008060408385031215610fbc57600080fd5b6000610fca85828601610e13565b9250506020610fdb85828601610dd4565b9150509250929050565b60008060408385031215610ff857600080fd5b600061100685828601610e28565b925050602061101785828601610dd4565b9150509250929050565b60006020828403121561103357600080fd5b600061104184828501610e52565b91505092915050565b61105381611381565b82525050565b61106281611393565b82525050565b600061107382611365565b61107d8185611370565b935061108d818560208601611426565b61109681611459565b840191505092915050565b60006110ae601a83611370565b91507f41525445513a2063616e6e6f74206163636570742065746865720000000000006000830152602082019050919050565b60006110ee601483611370565b91507f41525445513a206d7573742062652061646d696e0000000000000000000000006000830152602082019050919050565b61112a8161140f565b82525050565b61113981611419565b82525050565b6000602082019050611154600083018461104a565b92915050565b600060608201905061116f600083018661104a565b61117c602083018561104a565b611189604083018461104a565b949350505050565b600060a0820190506111a6600083018861104a565b6111b3602083018761104a565b6111c0604083018661104a565b6111cd6060830185611121565b6111da6080830184611121565b9695505050505050565b60006060820190506111f9600083018661104a565b611206602083018561104a565b6112136040830184611121565b949350505050565b6000608082019050611230600083018761104a565b61123d602083018661104a565b61124a6040830185611121565b6112576060830184611121565b95945050505050565b6000604082019050611275600083018561104a565b6112826020830184611059565b9392505050565b600060408201905061129e600083018561104a565b6112ab6020830184611121565b9392505050565b60006020820190506112c76000830184611059565b92915050565b600060208201905081810360008301526112e78184611068565b905092915050565b60006020820190508181036000830152611308816110a1565b9050919050565b60006020820190508181036000830152611328816110e1565b9050919050565b60006020820190506113446000830184611121565b92915050565b600060208201905061135f6000830184611130565b92915050565b600081519050919050565b600082825260208201905092915050565b600061138c826113ef565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006113d682611381565b9050919050565b60006113e882611381565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611444578082015181840152602081019050611429565b83811115611453576000848401525b50505050565b6000601f19601f8301169050919050565b61147381611381565b811461147e57600080fd5b50565b61148a81611393565b811461149557600080fd5b50565b6114a18161139f565b81146114ac57600080fd5b50565b6114b8816113cb565b81146114c357600080fd5b50565b6114cf816113dd565b81146114da57600080fd5b50565b6114e68161140f565b81146114f157600080fd5b5056fea2646970667358221220ec33b3869bd0dd4ece3ac2bbb7dd08f16df5eacc779a56550f522ed1d0db5b4a64736f6c63430008000033
[ 16, 2 ]
0xf3d4f2441474f76cbe6f572040edcc0152d7ba06
pragma solidity ^0.5.0; library SafeMath{ /** * Returns the addition of two unsigned integers, reverting on * overflow. * * - Addition cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } /** * Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * - 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; } } contract owned { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner,"ERC20: Required Owner !"); _; } function transferOwnership(address newOwner) onlyOwner public { require (newOwner != address(0),"ERC20 New Owner cannot be zero address"); owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external ; } contract TOKENERC20 { using SafeMath for uint256; // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; /* This generates a public event on the blockchain that will notify clients */ event Approval(address indexed _owner, address indexed _spender, uint256 _value); constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) private _allowance; mapping (address => bool) public LockList; mapping (address => uint256) public LockedTokens; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint256 _value) internal { uint256 stage; require(_from != address(0), "ERC20: transfer from the zero address"); require(_to != address(0), "ERC20: transfer to the zero address"); // Prevent transfer to 0x0 address. Use burn() instead require (LockList[msg.sender] == false,"ERC20: Caller Locked !"); // Check if msg.sender is locked or not require (LockList[_from] == false, "ERC20: Sender Locked !"); require (LockList[_to] == false,"ERC20: Receipient Locked !"); // Check if sender balance is locked stage=balanceOf[_from].sub(_value, "ERC20: transfer amount exceeds balance"); require (stage >= LockedTokens[_from],"ERC20: transfer amount exceeds Senders Locked Amount"); //Deduct and add balance balanceOf[_from]=stage; balanceOf[_to]=balanceOf[_to].add(_value,"ERC20: Addition overflow"); //emit Transfer event emit Transfer(_from, _to, _value); } /** * Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address _spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(_spender != address(0), "ERC20: approve to the zero address"); _allowance[owner][_spender] = amount; emit Approval(owner, _spender, amount); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns(bool){ _transfer(msg.sender, _to, _value); return true; } function burn(uint256 _value) public returns(bool){ require (LockList[msg.sender] == false,"ERC20: User Locked !"); uint256 stage; stage=balanceOf[msg.sender].sub(_value, "ERC20: transfer amount exceeds balance"); require (stage >= LockedTokens[msg.sender],"ERC20: transfer amount exceeds Senders Locked Amount"); balanceOf[msg.sender]=balanceOf[msg.sender].sub(_value,"ERC20: Burn amount exceeds balance."); totalSupply=totalSupply.sub(_value,"ERC20: Burn amount exceeds total supply"); emit Burn(msg.sender, _value); emit Transfer(msg.sender, address(0), _value); return true; } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param Account address * * @param _value the amount of money to burn * * Safely check if total supply is not overdrawn */ function burnFrom(address Account, uint256 _value) public returns (bool success) { require (LockList[msg.sender] == false,"ERC20: User Locked !"); require (LockList[Account] == false,"ERC20: Owner Locked !"); uint256 stage; require(Account != address(0), "ERC20: Burn from the zero address"); //Safely substract amount to be burned from callers allowance _approve(Account, msg.sender, _allowance[Account][msg.sender].sub(_value,"ERC20: burn amount exceeds allowance")); //Do not allow burn if Accounts tokens are locked. stage=balanceOf[Account].sub(_value,"ERC20: Transfer amount exceeds allowance"); require(stage>=LockedTokens[Account],"ERC20: Burn amount exceeds accounts locked amount"); balanceOf[Account] =stage ; // Subtract from the sender //Deduct burn amount from totalSupply totalSupply=totalSupply.sub(_value,"ERC20: Burn Amount exceeds totalSupply"); emit Burn(Account, _value); emit Transfer(Account, address(0), _value); return true; } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { _transfer(_from, _to, _value); _approve(_from,msg.sender,_allowance[_from][msg.sender].sub(_value,"ERC20: transfer amount exceeds allowance")); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * Emits Approval Event * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { uint256 unapprovbal; // Do not allow approval if amount exceeds locked amount unapprovbal=balanceOf[msg.sender].sub(_value,"ERC20: Allowance exceeds balance of approver"); require(unapprovbal>=LockedTokens[msg.sender],"ERC20: Approval amount exceeds locked amount "); _allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } function allowance(address _owner,address _spender) public view returns(uint256){ return _allowance[_owner][_spender]; } } contract StreamCoin is owned, TOKENERC20 { /* Initializes contract with initial supply tokens to the creator of the contract */ constructor () TOKENERC20( 100000000000 * 1 ** uint256(decimals), "Stream Coin", "STRM") public { } /** * User Lock * * @param Account the address of account to lock for transaction * * @param mode true or false for lock mode * */ function UserLock(address Account, bool mode) onlyOwner public { LockList[Account] = mode; } /** * Lock tokens * * @param Account the address of account to lock * * @param amount the amount of money to lock * * */ function LockTokens(address Account, uint256 amount) onlyOwner public{ LockedTokens[Account]=amount; } function UnLockTokens(address Account) onlyOwner public{ LockedTokens[Account]=0; } }
0x608060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461010c578063095ea7b31461019c57806311a5c3611461020f57806318160ddd1461026c5780631f846df41461029757806323b872dd14610300578063313ce5671461039357806342966c68146103c45780634723e1241461041757806350a8dbb71461046857806370a08231146104c357806379cc6790146105285780638da5cb5b1461059b57806395d89b41146105f2578063a26bddb414610682578063a9059cbb146106e7578063cae9ca511461075a578063dd62ed3e14610864578063f2fde38b146108e9575b600080fd5b34801561011857600080fd5b5061012161093a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610161578082015181840152602081019050610146565b50505050905090810190601f16801561018e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101a857600080fd5b506101f5600480360360408110156101bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109d8565b604051808215151515815260200191505060405180910390f35b34801561021b57600080fd5b5061026a6004803603604081101561023257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610c5b565b005b34801561027857600080fd5b50610281610d7a565b6040518082815260200191505060405180910390f35b3480156102a357600080fd5b506102e6600480360360208110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d80565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b506103796004803603606081101561032357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610da0565b604051808215151515815260200191505060405180910390f35b34801561039f57600080fd5b506103a8610eaf565b604051808260ff1660ff16815260200191505060405180910390f35b3480156103d057600080fd5b506103fd600480360360208110156103e757600080fd5b8101908080359060200190929190505050610ec2565b604051808215151515815260200191505060405180910390f35b34801561042357600080fd5b506104666004803603602081101561043a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611346565b005b34801561047457600080fd5b506104c16004803603604081101561048b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611452565b005b3480156104cf57600080fd5b50610512600480360360208110156104e657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061155e565b6040518082815260200191505060405180910390f35b34801561053457600080fd5b506105816004803603604081101561054b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611576565b604051808215151515815260200191505060405180910390f35b3480156105a757600080fd5b506105b0611bd5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105fe57600080fd5b50610607611bfa565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561064757808201518184015260208101905061062c565b50505050905090810190601f1680156106745780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561068e57600080fd5b506106d1600480360360208110156106a557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c98565b6040518082815260200191505060405180910390f35b3480156106f357600080fd5b506107406004803603604081101561070a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611cb0565b604051808215151515815260200191505060405180910390f35b34801561076657600080fd5b5061084a6004803603606081101561077d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156107c457600080fd5b8201836020820111156107d657600080fd5b803590602001918460018302840111640100000000831117156107f857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611cc7565b604051808215151515815260200191505060405180910390f35b34801561087057600080fd5b506108d36004803603604081101561088757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e4b565b6040518082815260200191505060405180910390f35b3480156108f557600080fd5b506109386004803603602081101561090c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611ed2565b005b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109d05780601f106109a5576101008083540402835291602001916109d0565b820191906000526020600020905b8154815290600101906020018083116109b357829003601f168201915b505050505081565b600080610a8b83606060405190810160405280602c81526020017f45524332303a20416c6c6f77616e636520657863656564732062616c616e636581526020017f206f6620617070726f7665720000000000000000000000000000000000000000815250600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b9050600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548110151515610b6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d8152602001807f45524332303a20417070726f76616c20616d6f756e742065786365656473206c81526020017f6f636b656420616d6f756e74200000000000000000000000000000000000000081525060400191505060405180910390fd5b82600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a3600191505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d1f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b80600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60045481565b60076020528060005260406000206000915054906101000a900460ff1681565b6000610dad848484612166565b610ea48433610e9f85606060405190810160405280602881526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206181526020017f6c6c6f77616e6365000000000000000000000000000000000000000000000000815250600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b61285f565b600190509392505050565b600360009054906101000a900460ff1681565b6000801515600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141515610f8b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f45524332303a2055736572204c6f636b6564202100000000000000000000000081525060200191505060405180910390fd5b600061103d83606060405190810160405280602681526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206281526020017f616c616e63650000000000000000000000000000000000000000000000000000815250600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b9050600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811015151561111c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001807f45524332303a207472616e7366657220616d6f756e742065786365656473205381526020017f656e64657273204c6f636b656420416d6f756e7400000000000000000000000081525060400191505060405180910390fd5b6111cc83606060405190810160405280602381526020017f45524332303a204275726e20616d6f756e7420657863656564732062616c616e81526020017f63652e0000000000000000000000000000000000000000000000000000000000815250600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061128283606060405190810160405280602781526020017f45524332303a204275726e20616d6f756e74206578636565647320746f74616c81526020017f20737570706c79000000000000000000000000000000000000000000000000008152506004546120a49092919063ffffffff16565b6004819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5846040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a36001915050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561140a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611516576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b80600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60056020528060005260406000206000915090505481565b6000801515600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561163f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f45524332303a2055736572204c6f636b6564202100000000000000000000000081525060200191505060405180910390fd5b60001515600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141515611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f45524332303a204f776e6572204c6f636b65642021000000000000000000000081525060200191505060405180910390fd5b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156117d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001807f45524332303a204275726e2066726f6d20746865207a65726f2061646472657381526020017f730000000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6118ca84336118c586606060405190810160405280602481526020017f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7781526020017f616e636500000000000000000000000000000000000000000000000000000000815250600660008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b61285f565b61197a83606060405190810160405280602881526020017f45524332303a205472616e7366657220616d6f756e742065786365656473206181526020017f6c6c6f77616e6365000000000000000000000000000000000000000000000000815250600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b9050600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548110151515611a59576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001807f45524332303a204275726e20616d6f756e742065786365656473206163636f7581526020017f6e7473206c6f636b656420616d6f756e7400000000000000000000000000000081525060400191505060405180910390fd5b80600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611b1083606060405190810160405280602681526020017f45524332303a204275726e20416d6f756e74206578636565647320746f74616c81526020017f537570706c7900000000000000000000000000000000000000000000000000008152506004546120a49092919063ffffffff16565b6004819055508373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5846040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611c905780601f10611c6557610100808354040283529160200191611c90565b820191906000526020600020905b815481529060010190602001808311611c7357829003601f168201915b505050505081565b60086020528060005260406000206000915090505481565b6000611cbd338484612166565b6001905092915050565b600080849050611cd785856109d8565b15611e42578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611dd1578082015181840152602081019050611db6565b50505050905090810190601f168015611dfe5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015611e2057600080fd5b505af1158015611e34573d6000803e3d6000fd5b505050506001915050611e44565b505b9392505050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611f96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f45524332303a205265717569726564204f776e6572202100000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515612061576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001807f4552433230204e6577204f776e65722063616e6e6f74206265207a65726f206181526020017f646472657373000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008383111582901515612153576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156121185780820151818401526020810190506120fd565b50505050905090810190601f1680156121455780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515612232576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001807f45524332303a207472616e736665722066726f6d20746865207a65726f20616481526020017f647265737300000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156122fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f45524332303a207472616e7366657220746f20746865207a65726f206164647281526020017f657373000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b60001515600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415156123c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f45524332303a2043616c6c6572204c6f636b656420210000000000000000000081525060200191505060405180910390fd5b60001515600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561248d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f45524332303a2053656e646572204c6f636b656420210000000000000000000081525060200191505060405180910390fd5b60001515600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141515612555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f45524332303a2052656365697069656e74204c6f636b6564202100000000000081525060200191505060405180910390fd5b61260582606060405190810160405280602681526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206281526020017f616c616e63650000000000000000000000000000000000000000000000000000815250600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a49092919063ffffffff16565b9050600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481101515156126e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001807f45524332303a207472616e7366657220616d6f756e742065786365656473205381526020017f656e64657273204c6f636b656420416d6f756e7400000000000000000000000081525060400191505060405180910390fd5b80600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127b1826040805190810160405280601881526020017f45524332303a204164646974696f6e206f766572666c6f770000000000000000815250600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612ae09092919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561292a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001807f45524332303a20617070726f76652066726f6d20746865207a65726f2061646481526020017f726573730000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156129f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001807f45524332303a20617070726f766520746f20746865207a65726f20616464726581526020017f737300000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b60008083850190508481101583901515612b95576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612b5a578082015181840152602081019050612b3f565b50505050905090810190601f168015612b875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080915050939250505056fea165627a7a72305820243cfc6a5fa316e9d9da4f40b9debdb598699992e75a888b189f1cbf7c8003af0029
[ 38 ]
0xf3d513fa681ff6f8f7557533d19aea6a20b961f2
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol // 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); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } // File: contracts/v612/ERC95.sol // COPYRIGHT cVault.finance TEAM // NO COPY // COPY = BAD // This code is provided with no assurances or guarantees of any kind. Use at your own responsibility. pragma experimental ABIEncoderV2; // # ERC95 technical documentation // tl;dr - ERC95 is a wrap for one or more underlying tokens. // It can be eg. cYFI or 25% cYFI 10% AMPL 50% X // This balances are unchangeable. // Name of this token should be standardised // cX for X coin // For partial coins eg. // 25cX+25cY+50cZ // Tokens should be able to be multiwrappable, into any derivatives. // special carveout for LP tokens naming should be // 50lpX+25lpY+25lpZ // special carveout for leveraged multiplier tokens // x25Y+x50Z // All prefixes are lowercase : // c for CORE wrap // x for times ( leverage ) - not clear how this would work right now but its on the goal list // lp for Liquidity pool token. // Short term goal for ERC95 is to start few LGEs and lock liquidity in pairs with them // Long term goal is to pay out everyones fees and let anyone create a pair with CORE with any wrap or derivative they want. And pay out fees on that pair to them, in a permisionless way // That benefits CORE/LP holders by a part of the fees from those and all other pairs. // This will be ensured in CoreVault but I outlined it here so the goal of this is clear. // ## Token wrap token // A token wrapping standard. // Recieves token, issues cToken // eg. YFI -> cYFI // Unwrapping and wrapping should be fee-less and permissionless the same principles as WETH. // Note : This might need to be 20 decimals. Because of change of holding multiple tokens under one. // I'm not sure about support for this everywhere. - will it break websites? // import "@openzeppelin/contracts/GSN/Context.sol"; contract ERC95 is ContextUpgradeSafe, IERC20 { // XXXXX Ownable is new using SafeMath for uint256; using SafeMath for uint8; /// XXXXX ERC95 Specific functions // Events event Wrapped(address indexed from, address indexed to, uint256 amount); event Unwrapped(address indexed from, address indexed to, uint256 amount); uint8 public _numTokensWrapped; WrappedToken[] public _wrappedTokens; // Structs struct WrappedToken { address _address; uint256 _reserve; uint256 _amountWrapperPerUnit; } function _setName(string memory name) internal { _name = name; } function __ERC95_init(string memory name, string memory symbol, address[] memory _addresses, uint8[] memory _percent, uint8[] memory tokenDecimals) public initializer { ContextUpgradeSafe.__Context_init_unchained(); // We check if numbers are supplied 1:1 // And get the total number of them. require(_addresses.length == _percent.length, "ERC95 : Mismatch num tokens"); uint8 decimalsMax; uint percentTotal; // To make sure they add up to 100 uint8 numTokensWrapped = 0; for (uint256 loop = 0; loop < _addresses.length; loop++) { // 0 % tokens cannnot be permitted require(_percent[loop] > 0 ,"ERC95 : All wrapped tokens have to have at least 1% of total"); // we check the decimals of current token // decimals is not part of erc20 standard, and is safer to provide in the caller // tokenDecimals[loop] = IERC20(_addresses[loop]).decimals(); decimalsMax = tokenDecimals[loop] > decimalsMax ? tokenDecimals[loop] : decimalsMax; // pick max percentTotal += _percent[loop]; // further for checking everything adds up //_numTokensWrapped++; // we might just assign this numTokensWrapped++; } require(percentTotal == 100, "ERC95 : Percent of all wrapped tokens should equal 100"); require(numTokensWrapped == _addresses.length, "ERC95 : Length mismatch sanity check fail"); // Is this sanity check needed? // No, but let's leave it anyway in case it becomes needed later _numTokensWrapped = numTokensWrapped; // Loop over all tokens against to populate the structs for (uint256 loop = 0; loop < numTokensWrapped; loop++) { // We get the difference between decimals because 6 decimal token should have 1000000000000000000 in 18 decimal token per unit uint256 decimalDifference = decimalsMax - tokenDecimals[loop]; // 10 ** 0 is 1 so good // cast to safemath uint256 pAmountWrapperPerUnit = numTokensWrapped > 1 ? (10**decimalDifference).mul(_percent[loop]) : 1; _wrappedTokens.push( WrappedToken({ _address: _addresses[loop], _reserve: 0, /* TODO: I don't know what reserve does here so just stick 0 in it */ _amountWrapperPerUnit : pAmountWrapperPerUnit // if its one token then we can have the same decimals /// 10*0 = 1 * 1 = 1 /// 10*0 = 1 * 50 = 50 this means half because +2 decimals }) ); } _name = name; _symbol = symbol; // we dont need more decimals if its 1 token wraped _decimals = numTokensWrapped > 1 ? decimalsMax + 2 : decimalsMax; // 2 more decimals to support percentage wraps we support up to 1%-100% in integers } // returns info for a token with x id in the loop function getTokenInfo(uint _id) public view returns (address, uint256, uint256) { WrappedToken memory wt = _wrappedTokens[_id]; return (wt._address, wt._reserve, wt._amountWrapperPerUnit); } // Mints the ERC20 during a wrap function _mintWrap(address to, uint256 amt) internal { _mint(to, amt); emit Wrapped(msg.sender, to, amt); } // burns the erc and sends underlying tokens function _unwrap(address from, address to, uint256 amt) internal { _burn(from, amt); sendUnderlyingTokens(to, amt); emit Unwrapped(from, to, amt); } /// public function to unwrap function unwrap(uint256 amt) public { _unwrap(msg.sender, msg.sender, amt); } function unwrapAll() public { unwrap(_balances[msg.sender]); } // TODO: Unit test with USDT // TODO: use the safetransfer shit from uinswap // TODO: Account for decimals in transfer amt (EtherDelta and IDEX would have this logic already) // TODO: Land-mine testing of USDT function sendUnderlyingTokens(address to, uint256 amt) internal { for (uint256 loop = 0; loop < _numTokensWrapped; loop++) { WrappedToken storage currentToken = _wrappedTokens[loop]; uint256 amtToSend = amt.mul(currentToken._amountWrapperPerUnit); safeTransfer(currentToken._address, to, amtToSend); currentToken._reserve = currentToken._reserve.sub(amtToSend); } } function safeTransfer(address token, address to, uint256 value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ERC95: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint256 value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ERC95: TRANSFER_FROM_FAILED'); } // You can unwrap if you have allowance to erc20 wrap function unwrapFor(address spender, uint256 amt) public { require(_allowances[spender][msg.sender] >= amt, "ERC95 allowance exceded"); _unwrap(spender, msg.sender, amt); _allowances[spender][msg.sender] = _allowances[spender][msg.sender].sub(amt); } // Loops over all tokens in the wrap and deposits them with allowance function _depositUnderlying(uint256 amt) internal { for (uint256 loop = 0; loop < _numTokensWrapped; loop++) { WrappedToken memory currentToken = _wrappedTokens[loop]; // req successful transfer uint256 amtToSend = amt.mul(currentToken._amountWrapperPerUnit); safeTransferFrom(currentToken._address, msg.sender, address(this), amtToSend); // Transfer went OK this means we can add this balance we just took. _wrappedTokens[loop]._reserve = currentToken._reserve.add(amtToSend); } } // Deposits by checking against reserves function wrapAtomic(address to) noNullAddress(to) public { uint256 amt = _updateReserves(); _mintWrap(to, amt); } // public function to call the deposit with allowance and mint function wrap(address to, uint256 amt) noNullAddress(to) public { // works as wrap for _depositUnderlying(amt); _mintWrap(to, amt); // No need to check underlying? } // safety for front end bugs modifier noNullAddress(address to) { require(to != address(0), "ERC95 : null address safety check"); _; } function _updateReserves() internal returns (uint256 qtyOfNewTokens) { // Loop through all tokens wrapped, and find the maximum quantity of wrapped tokens that can be created, given the balance delta for this block for (uint256 loop = 0; loop < _numTokensWrapped; loop++) { WrappedToken memory currentToken = _wrappedTokens[loop]; uint256 currentTokenBal = IERC20(currentToken._address).balanceOf(address(this)); // TODO: update to not use percentages uint256 amtCurrent = currentTokenBal.sub(currentToken._reserve).div(currentToken._amountWrapperPerUnit); // math check pls qtyOfNewTokens = qtyOfNewTokens > amtCurrent ? amtCurrent : qtyOfNewTokens; // logic check // pick lowest amount so dust attack doesn't work // can't skim in txs or they have non-deterministic gas price if(loop == 0) { qtyOfNewTokens = amtCurrent; } } // second loop makes reserve numbers match from computed amount for (uint256 loop2 = 0; loop2 < _numTokensWrapped; loop2++) { WrappedToken memory currentToken = _wrappedTokens[loop2]; uint256 amtDelta = qtyOfNewTokens.mul(currentToken._amountWrapperPerUnit);// math check pls _wrappedTokens[loop2]._reserve = currentToken._reserve.add(amtDelta);// math check pls } } // Force to match reserves by transfering out to anyone the excess function skim(address to) public { for (uint256 loop = 0; loop < _numTokensWrapped; loop++) { WrappedToken memory currentToken = _wrappedTokens[loop]; uint256 currentTokenBal = IERC20(currentToken._address).balanceOf(address(this)); uint256 excessTokensQuantity = currentTokenBal.sub(currentToken._reserve); if(excessTokensQuantity > 0) { safeTransfer(currentToken._address , to, excessTokensQuantity); } } } /// END ERC95 SPECIFIC FUNCTIONS START ERC20 // we propably should inherit ERC20 somehow 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 Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } // File: @openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } uint256[49] private __gap; } // File: contracts/v612/cBTC.sol pragma solidity 0.6.12; interface ICOREGlobals { function TransferHandler() external returns (address); } interface ICORETransferHandler{ function handleTransfer(address, address, uint256) external; } contract cBTC is OwnableUpgradeSafe, ERC95 { bool public paused; // Once only unpause address LGEAddress; ICOREGlobals coreGlobals; function initialize(address[] memory _addresses, uint8[] memory _percent, uint8[] memory tokenDecimals, address _coreGlobals) public initializer { require(tx.origin == address(0x5A16552f59ea34E44ec81E58b3817833E9fD5436)); OwnableUpgradeSafe.__Ownable_init(); ERC95.__ERC95_init("cVault.finance/cBTC", "cBTC", _addresses, _percent, tokenDecimals); coreGlobals = ICOREGlobals(_coreGlobals); paused = true; } function changeWrapTokenName(string memory name) public onlyOwner { _setName(name); } // Changing it after does nothing, all this can do is unpause once. function setLGEAddress(address _LGEAddress) public onlyOwner { LGEAddress = _LGEAddress; } // Unpauses transfers of this once // This is needed so people don't wrap before LGE isover and screw liquidity adds function unpauseTransfers() public onlyLGEContract { paused = false; } // Checks if contract is LGE address modifier onlyLGEContract { require(LGEAddress != address(0), "Address not set"); require(msg.sender == LGEAddress, "Not LGE address"); _; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { require(paused == false, "Transfers paused until LGE is over"); ICORETransferHandler(coreGlobals.TransferHandler()).handleTransfer(from, to, amount); } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80638936a91f11610104578063bc25cf77116100a2578063db75ec4811610071578063db75ec481461039c578063dd62ed3e146103af578063de0e9a3e146103c2578063f2fde38b146103d5576101cf565b8063bc25cf7714610350578063bf376c7a14610363578063c4d352aa14610376578063d5d1ebd514610389576101cf565b80638da5cb5b116100de5780638da5cb5b1461030d57806395d89b4114610322578063a457c2d71461032a578063a9059cbb1461033d576101cf565b80638936a91f146102df5780638c7a63ae146102e75780638cbc3ae5146102fa576101cf565b806339509351116101715780635c975abb1161014b5780635c975abb1461029a57806370a08231146102a2578063715018a6146102b557806371882795146102bd576101cf565b8063395093511461026c5780633d669f8c1461027f5780634982e3b714610292576101cf565b806318160ddd116101ad57806318160ddd1461022757806323b872dd1461023c578063313ce5671461024f5780633937f81714610257576101cf565b806306fdde03146101d4578063095ea7b3146101f25780630aa57dfe14610212575b600080fd5b6101dc6103e8565b6040516101e99190612ce8565b60405180910390f35b610205610200366004612a02565b61049c565b6040516101e99190612cdd565b61021a6104ba565b6040516101e991906133e8565b61022f6104c3565b6040516101e991906133df565b61020561024a3660046129c2565b6104c9565b61021a61056a565b61026a610265366004612ae4565b610573565b005b61020561027a366004612a02565b6105e4565b61026a61028d366004612952565b61063f565b61026a6106a8565b6102056106c3565b61022f6102b0366004612952565b6106d1565b61026a6106f9565b6102d06102cb366004612beb565b6107c4565b6040516101e993929190612caf565b61026a61080b565b6102d06102f5366004612beb565b6108e1565b61026a610308366004612a02565b610958565b610315610a40565b6040516101e99190612c37565b6101dc610a5c565b610205610338366004612a02565b610adb565b61020561034b366004612a02565b610b50565b61026a61035e366004612952565b610b64565b61026a610371366004612a02565b610c9f565b61026a610384366004612b1f565b610d00565b61026a610397366004612a2d565b61113f565b61026a6103aa366004612952565b611345565b61022f6103bd36600461298a565b6113ee565b61026a6103d0366004612beb565b611426565b61026a6103e3366004612952565b611431565b609c8054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104925780601f1061046757610100808354040283529160200191610492565b820191906000526020600020905b81548152906001019060200180831161047557829003601f168201915b5050505050905090565b60006104b06104a9611568565b848461156c565b5060015b92915050565b60975460ff1681565b609b5490565b60006104d684848461167b565b610560846104e2611568565b61055b856040518060600160405280602881526020016134d86028913973ffffffffffffffffffffffffffffffffffffffff8a166000908152609a602052604081209061052d611568565b73ffffffffffffffffffffffffffffffffffffffff1681526020810191909152604001600020549190611805565b61156c565b5060019392505050565b609e5460ff1690565b61057b611568565b60655473ffffffffffffffffffffffffffffffffffffffff9081169116146105d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613134565b60405180910390fd5b6105e18161184b565b50565b60006104b06105f1611568565b8461055b85609a6000610602611568565b73ffffffffffffffffffffffffffffffffffffffff908116825260208083019390935260409182016000908120918c16815292529020549061185e565b8073ffffffffffffffffffffffffffffffffffffffff811661068d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf9061300c565b60006106976118a4565b90506106a38382611aba565b505050565b336000908152609960205260409020546106c190611426565b565b609e54610100900460ff1681565b73ffffffffffffffffffffffffffffffffffffffff1660009081526099602052604090205490565b610701611568565b60655473ffffffffffffffffffffffffffffffffffffffff908116911614610755576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613134565b60655460405160009173ffffffffffffffffffffffffffffffffffffffff16907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b609881815481106107d157fe5b600091825260209091206003909102018054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff909116925083565b609e5462010000900473ffffffffffffffffffffffffffffffffffffffff16610860576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612f78565b609e5462010000900473ffffffffffffffffffffffffffffffffffffffff1633146108b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613314565b609e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055565b60008060006108ee61271a565b609885815481106108fb57fe5b600091825260209182902060408051606081018252600393909302909101805473ffffffffffffffffffffffffffffffffffffffff1680845260018201549484018590526002909101549290910182905297919650945092505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152609a602090815260408083203384529091529020548111156109c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613069565b6109cd823383611b2d565b73ffffffffffffffffffffffffffffffffffffffff82166000908152609a60209081526040808320338452909152902054610a089082611b9e565b73ffffffffffffffffffffffffffffffffffffffff9092166000908152609a6020908152604080832033845290915290209190915550565b60655473ffffffffffffffffffffffffffffffffffffffff1690565b609d8054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104925780601f1061046757610100808354040283529160200191610492565b60006104b0610ae8611568565b8461055b8560405180606001604052806025815260200161350060259139609a6000610b12611568565b73ffffffffffffffffffffffffffffffffffffffff908116825260208083019390935260409182016000908120918d16815292529020549190611805565b60006104b0610b5d611568565b848461167b565b60005b60975460ff16811015610c9b57610b7c61271a565b60988281548110610b8957fe5b60009182526020808320604080516060810182526003909402909101805473ffffffffffffffffffffffffffffffffffffffff168085526001820154938501939093526002015483820152517f70a08231000000000000000000000000000000000000000000000000000000008152919350906370a0823190610c10903090600401612c37565b60206040518083038186803b158015610c2857600080fd5b505afa158015610c3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c609190612c03565b90506000610c7b836020015183611b9e90919063ffffffff16565b90508015610c90578251610c90908683611be0565b505050600101610b67565b5050565b8173ffffffffffffffffffffffffffffffffffffffff8116610ced576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf9061300c565b610cf682611d03565b6106a38383611aba565b600054610100900460ff1680610d195750610d19611dd6565b80610d27575060005460ff16155b610d5d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613169565b600054610100900460ff16158015610dc357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b610dcb611ddc565b8251845114610e06576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf906130a0565b6000806000805b8751811015610ece576000878281518110610e2457fe5b602002602001015160ff1611610e66576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612e2a565b8360ff16868281518110610e7657fe5b602002602001015160ff1611610e8c5783610ea1565b858181518110610e9857fe5b60200260200101515b9350868181518110610eaf57fe5b602090810291909101015160ff16929092019160019182019101610e0d565b5081606414610f09576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf9061334b565b86518160ff1614610f46576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612dcd565b609780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff831617905560005b8160ff16811015611093576000868281518110610f8f57fe5b6020026020010151850360ff169050600060018460ff1611610fb2576001610fde565b610fde898481518110610fc157fe5b602002602001015160ff1683600a0a611ed090919063ffffffff16565b9050609860405180606001604052808c8681518110610ff957fe5b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff9081168352600083830181905260409384019690965284546001808201875595875295829020845160039097020180547fffffffffffffffffffffffff00000000000000000000000000000000000000001696909116959095178555820151848401550151600290920191909155919091019050610f76565b5088516110a790609c9060208c0190612751565b5087516110bb90609d9060208b0190612751565b5060018160ff16116110cd57826110d2565b826002015b609e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9290921691909117905550508115905061113757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b505050505050565b600054610100900460ff16806111585750611158611dd6565b80611166575060005460ff16155b61119c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613169565b600054610100900460ff1615801561120257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b32735a16552f59ea34e44ec81e58b3817833e9fd54361461122257600080fd5b61122a611f24565b6112a16040518060400160405280601381526020017f635661756c742e66696e616e63652f63425443000000000000000000000000008152506040518060400160405280600481526020017f6342544300000000000000000000000000000000000000000000000000000000815250878787610d00565b609f805473ffffffffffffffffffffffffffffffffffffffff84167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179055609e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100179055801561133e57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b5050505050565b61134d611568565b60655473ffffffffffffffffffffffffffffffffffffffff9081169116146113a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613134565b609e805473ffffffffffffffffffffffffffffffffffffffff90921662010000027fffffffffffffffffffff0000000000000000000000000000000000000000ffff909216919091179055565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152609a6020908152604080832093909416825291909152205490565b6105e1333383611b2d565b611439611568565b60655473ffffffffffffffffffffffffffffffffffffffff90811691161461148d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613134565b73ffffffffffffffffffffffffffffffffffffffff81166114da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612e87565b60655460405173ffffffffffffffffffffffffffffffffffffffff8084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3606580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3390565b73ffffffffffffffffffffffffffffffffffffffff83166115b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf906132b7565b73ffffffffffffffffffffffffffffffffffffffff8216611606576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612ee4565b73ffffffffffffffffffffffffffffffffffffffff8084166000818152609a602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061166e9085906133df565b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff83166116c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613223565b73ffffffffffffffffffffffffffffffffffffffff8216611715576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612d39565b611720838383611ff7565b61176a816040518060600160405280602681526020016134b26026913973ffffffffffffffffffffffffffffffffffffffff86166000908152609960205260409020549190611805565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526099602052604080822093909355908416815220546117a6908261185e565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526099602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061166e9085906133df565b60008184841115611843576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf9190612ce8565b505050900390565b8051610c9b90609c906020840190612751565b60008282018381101561189d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612f41565b9392505050565b6000805b60975460ff168110156119f1576118bd61271a565b609882815481106118ca57fe5b60009182526020808320604080516060810182526003909402909101805473ffffffffffffffffffffffffffffffffffffffff168085526001820154938501939093526002015483820152517f70a08231000000000000000000000000000000000000000000000000000000008152919350906370a0823190611951903090600401612c37565b60206040518083038186803b15801561196957600080fd5b505afa15801561197d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a19190612c03565b905060006119ca83604001516119c4856020015185611b9e90919063ffffffff16565b9061214e565b90508085116119d957846119db565b805b9450836119e6578094505b5050506001016118a8565b5060005b60975460ff16811015611ab657611a0a61271a565b60988281548110611a1757fe5b60009182526020808320604080516060810182526003909402909101805473ffffffffffffffffffffffffffffffffffffffff168452600181015492840192909252600290910154908201819052909250611a73908590611ed0565b6020830151909150611a85908261185e565b60988481548110611a9257fe5b906000526020600020906003020160010181905550505080806001019150506119f5565b5090565b611ac48282612190565b8173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f29b3b451f9779df34ec8a67ec6c96fa910b17a579a66b7428d94f481be6900d983604051611b2191906133df565b60405180910390a35050565b611b378382612285565b611b4182826123a9565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f742cbb4a6bddd5e23aa0c14356065c236bdbc921cddb7f1f763161eb2030f3ef8360405161166e91906133df565b600061189d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611805565b600060608473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401611c13929190612c89565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051611c619190612c1b565b6000604051808303816000865af19150503d8060008114611c9e576040519150601f19603f3d011682016040523d82523d6000602084013e611ca3565b606091505b5091509150818015611ccd575080511580611ccd575080806020019051810190611ccd9190612ac4565b61133e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612d96565b60005b60975460ff16811015610c9b57611d1b61271a565b60988281548110611d2857fe5b60009182526020808320604080516060810182526003909402909101805473ffffffffffffffffffffffffffffffffffffffff168452600181015492840192909252600290910154908201819052909250611d84908590611ed0565b9050611d968260000151333084612433565b6020820151611da5908261185e565b60988481548110611db257fe5b90600052602060002090600302016001018190555050508080600101915050611d06565b303b1590565b600054610100900460ff1680611df55750611df5611dd6565b80611e03575060005460ff16155b611e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613169565b600054610100900460ff16158015611e9f57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b80156105e157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b600082611edf575060006104b4565b82820282848281611eec57fe5b041461189d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf906130d7565b600054610100900460ff1680611f3d5750611f3d611dd6565b80611f4b575060005460ff16155b611f81576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613169565b600054610100900460ff16158015611fe757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b611fef611ddc565b611e9f612558565b609e54610100900460ff1615612039576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90612faf565b609f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663242c29296040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156120a357600080fd5b505af11580156120b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120db919061296e565b73ffffffffffffffffffffffffffffffffffffffff166346197c9a8484846040518463ffffffff1660e01b815260040161211793929190612c58565b600060405180830381600087803b15801561213157600080fd5b505af1158015612145573d6000803e3d6000fd5b50505050505050565b600061189d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506126c9565b73ffffffffffffffffffffffffffffffffffffffff82166121dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf906133a8565b6121e960008383611ff7565b609b546121f6908261185e565b609b5573ffffffffffffffffffffffffffffffffffffffff8216600090815260996020526040902054612229908261185e565b73ffffffffffffffffffffffffffffffffffffffff83166000818152609960205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611b219085906133df565b73ffffffffffffffffffffffffffffffffffffffff82166122d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf906131c6565b6122de82600083611ff7565b612328816040518060600160405280602281526020016134906022913973ffffffffffffffffffffffffffffffffffffffff85166000908152609960205260409020549190611805565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260996020526040902055609b5461235b9082611b9e565b609b5560405160009073ffffffffffffffffffffffffffffffffffffffff8416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611b219085906133df565b60005b60975460ff168110156106a3576000609882815481106123c857fe5b9060005260206000209060030201905060006123f1826002015485611ed090919063ffffffff16565b82549091506124179073ffffffffffffffffffffffffffffffffffffffff168683611be0565b60018201546124269082611b9e565b60019283015550016123ac565b600060608573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161246893929190612c58565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516124b69190612c1b565b6000604051808303816000865af19150503d80600081146124f3576040519150601f19603f3d011682016040523d82523d6000602084013e6124f8565b606091505b50915091508180156125225750805115806125225750808060200190518101906125229190612ac4565b611137576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613280565b600054610100900460ff16806125715750612571611dd6565b8061257f575060005460ff16155b6125b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf90613169565b600054610100900460ff1615801561261b57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909116610100171660011790555b6000612625611568565b606580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156105e157600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b60008183612704576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cf9190612ce8565b50600083858161271057fe5b0495945050505050565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061279257805160ff19168380011785556127bf565b828001600101855582156127bf579182015b828111156127bf5782518255916020019190600101906127a4565b50611ab69291505b80821115611ab657600081556001016127c7565b600082601f8301126127eb578081fd5b81356127fe6127f98261341d565b6133f6565b81815291506020808301908481018184028601820187101561281f57600080fd5b60005b848110156128475781356128358161346d565b84529282019290820190600101612822565b505050505092915050565b600082601f830112612862578081fd5b81356128706127f98261341d565b81815291506020808301908481018184028601820187101561289157600080fd5b6000805b858110156128bf57823560ff811681146128ad578283fd5b85529383019391830191600101612895565b50505050505092915050565b600082601f8301126128db578081fd5b813567ffffffffffffffff8111156128f1578182fd5b61292260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016133f6565b915080825283602082850101111561293957600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612963578081fd5b813561189d8161346d565b60006020828403121561297f578081fd5b815161189d8161346d565b6000806040838503121561299c578081fd5b82356129a78161346d565b915060208301356129b78161346d565b809150509250929050565b6000806000606084860312156129d6578081fd5b83356129e18161346d565b925060208401356129f18161346d565b929592945050506040919091013590565b60008060408385031215612a14578182fd5b8235612a1f8161346d565b946020939093013593505050565b60008060008060808587031215612a42578081fd5b843567ffffffffffffffff80821115612a59578283fd5b612a65888389016127db565b95506020870135915080821115612a7a578283fd5b612a8688838901612852565b94506040870135915080821115612a9b578283fd5b50612aa887828801612852565b9250506060850135612ab98161346d565b939692955090935050565b600060208284031215612ad5578081fd5b8151801515811461189d578182fd5b600060208284031215612af5578081fd5b813567ffffffffffffffff811115612b0b578182fd5b612b17848285016128cb565b949350505050565b600080600080600060a08688031215612b36578081fd5b853567ffffffffffffffff80821115612b4d578283fd5b612b5989838a016128cb565b96506020880135915080821115612b6e578283fd5b612b7a89838a016128cb565b95506040880135915080821115612b8f578283fd5b612b9b89838a016127db565b94506060880135915080821115612bb0578283fd5b612bbc89838a01612852565b93506080880135915080821115612bd1578283fd5b50612bde88828901612852565b9150509295509295909350565b600060208284031215612bfc578081fd5b5035919050565b600060208284031215612c14578081fd5b5051919050565b60008251612c2d81846020870161343d565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9390931683526020830191909152604082015260600190565b901515815260200190565b6000602082528251806020840152612d0781604085016020870161343d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201527f6573730000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526016908201527f45524339353a205452414e534645525f4641494c454400000000000000000000604082015260600190565b60208082526029908201527f4552433935203a204c656e677468206d69736d617463682073616e697479206360408201527f6865636b206661696c0000000000000000000000000000000000000000000000606082015260800190565b6020808252603c908201527f4552433935203a20416c6c207772617070656420746f6b656e7320686176652060408201527f746f2068617665206174206c65617374203125206f6620746f74616c00000000606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201527f6464726573730000000000000000000000000000000000000000000000000000606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560408201527f7373000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600f908201527f41646472657373206e6f74207365740000000000000000000000000000000000604082015260600190565b60208082526022908201527f5472616e73666572732070617573656420756e74696c204c4745206973206f7660408201527f6572000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f4552433935203a206e756c6c206164647265737320736166657479206368656360408201527f6b00000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f455243393520616c6c6f77616e63652065786365646564000000000000000000604082015260600190565b6020808252601b908201527f4552433935203a204d69736d61746368206e756d20746f6b656e730000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60408201527f7700000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201527f656e20696e697469616c697a6564000000000000000000000000000000000000606082015260800190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360408201527f7300000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460408201527f6472657373000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601b908201527f45524339353a205452414e534645525f46524f4d5f4641494c45440000000000604082015260600190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460408201527f7265737300000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252600f908201527f4e6f74204c474520616464726573730000000000000000000000000000000000604082015260600190565b60208082526036908201527f4552433935203a2050657263656e74206f6620616c6c2077726170706564207460408201527f6f6b656e732073686f756c6420657175616c2031303000000000000000000000606082015260800190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b60ff91909116815260200190565b60405181810167ffffffffffffffff8111828210171561341557600080fd5b604052919050565b600067ffffffffffffffff821115613433578081fd5b5060209081020190565b60005b83811015613458578181015183820152602001613440565b83811115613467576000848401525b50505050565b73ffffffffffffffffffffffffffffffffffffffff811681146105e157600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220307182c6be631cfc4afa6eaccd2850d68dd0773fb3b8a8f79571cd1616b1ce2764736f6c634300060c0033
[ 21, 7, 9, 12 ]
0xf3d58D1794f2634d6649a978f2dc093898FEEBc0
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import { iL1ChugSplashDeployer } from "./interfaces/iL1ChugSplashDeployer.sol"; /** * @title L1ChugSplashProxy * @dev Basic ChugSplash proxy contract for L1. Very close to being a normal proxy but has added * functions `setCode` and `setStorage` for changing the code or storage of the contract. Nifty! * * Note for future developers: do NOT make anything in this contract 'public' unless you know what * you're doing. Anything public can potentially have a function signature that conflicts with a * signature attached to the implementation contract. Public functions SHOULD always have the * 'proxyCallIfNotOwner' modifier unless there's some *really* good reason not to have that * modifier. And there almost certainly is not a good reason to not have that modifier. Beware! */ contract L1ChugSplashProxy { /************* * Constants * *************/ // "Magic" prefix. When prepended to some arbitrary bytecode and used to create a contract, the // appended bytecode will be deployed as given. bytes13 internal constant DEPLOY_CODE_PREFIX = 0x600D380380600D6000396000f3; // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) bytes32 internal constant IMPLEMENTATION_KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; // bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1) bytes32 internal constant OWNER_KEY = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /*************** * Constructor * ***************/ /** * @param _owner Address of the initial contract owner. */ constructor(address _owner) { _setOwner(_owner); } /********************** * Function Modifiers * **********************/ /** * Blocks a function from being called when the parent signals that the system should be paused * via an isUpgrading function. */ modifier onlyWhenNotPaused() { address owner = _getOwner(); // We do a low-level call because there's no guarantee that the owner actually *is* an // L1ChugSplashDeployer contract and Solidity will throw errors if we do a normal call and // it turns out that it isn't the right type of contract. (bool success, bytes memory returndata) = owner.staticcall( abi.encodeWithSelector(iL1ChugSplashDeployer.isUpgrading.selector) ); // If the call was unsuccessful then we assume that there's no "isUpgrading" method and we // can just continue as normal. We also expect that the return value is exactly 32 bytes // long. If this isn't the case then we can safely ignore the result. if (success && returndata.length == 32) { // Although the expected value is a *boolean*, it's safer to decode as a uint256 in the // case that the isUpgrading function returned something other than 0 or 1. But we only // really care about the case where this value is 0 (= false). uint256 ret = abi.decode(returndata, (uint256)); require(ret == 0, "L1ChugSplashProxy: system is currently being upgraded"); } _; } /** * Makes a proxy call instead of triggering the given function when the caller is either the * owner or the zero address. Caller can only ever be the zero address if this function is * being called off-chain via eth_call, which is totally fine and can be convenient for * client-side tooling. Avoids situations where the proxy and implementation share a sighash * and the proxy function ends up being called instead of the implementation one. * * Note: msg.sender == address(0) can ONLY be triggered off-chain via eth_call. If there's a * way for someone to send a transaction with msg.sender == address(0) in any real context then * we have much bigger problems. Primary reason to include this additional allowed sender is * because the owner address can be changed dynamically and we do not want clients to have to * keep track of the current owner in order to make an eth_call that doesn't trigger the * proxied contract. */ modifier proxyCallIfNotOwner() { if (msg.sender == _getOwner() || msg.sender == address(0)) { _; } else { // This WILL halt the call frame on completion. _doProxyCall(); } } /********************* * Fallback Function * *********************/ fallback() external payable { // Proxy call by default. _doProxyCall(); } /******************** * Public Functions * ********************/ /** * Sets the code that should be running behind this proxy. Note that this scheme is a bit * different from the standard proxy scheme where one would typically deploy the code * separately and then set the implementation address. We're doing it this way because it gives * us a lot more freedom on the client side. Can only be triggered by the contract owner. * @param _code New contract code to run inside this contract. */ function setCode(bytes memory _code) public proxyCallIfNotOwner { // Get the code hash of the current implementation. address implementation = _getImplementation(); // If the code hash matches the new implementation then we return early. if (keccak256(_code) == _getAccountCodeHash(implementation)) { return; } // Create the deploycode by appending the magic prefix. bytes memory deploycode = abi.encodePacked(DEPLOY_CODE_PREFIX, _code); // Deploy the code and set the new implementation address. address newImplementation; assembly { newImplementation := create(0x0, add(deploycode, 0x20), mload(deploycode)) } // Check that the code was actually deployed correctly. I'm not sure if you can ever // actually fail this check. Should only happen if the contract creation from above runs // out of gas but this parent execution thread does NOT run out of gas. Seems like we // should be doing this check anyway though. require( _getAccountCodeHash(newImplementation) == keccak256(_code), "L1ChugSplashProxy: code was not correctly deployed." ); _setImplementation(newImplementation); } /** * Modifies some storage slot within the proxy contract. Gives us a lot of power to perform * upgrades in a more transparent way. Only callable by the owner. * @param _key Storage key to modify. * @param _value New value for the storage key. */ function setStorage(bytes32 _key, bytes32 _value) public proxyCallIfNotOwner { assembly { sstore(_key, _value) } } /** * Changes the owner of the proxy contract. Only callable by the owner. * @param _owner New owner of the proxy contract. */ function setOwner(address _owner) public proxyCallIfNotOwner { _setOwner(_owner); } /** * Queries the owner of the proxy contract. Can only be called by the owner OR by making an * eth_call and setting the "from" address to address(0). * @return Owner address. */ function getOwner() public proxyCallIfNotOwner returns (address) { return _getOwner(); } /** * Queries the implementation address. Can only be called by the owner OR by making an * eth_call and setting the "from" address to address(0). * @return Implementation address. */ function getImplementation() public proxyCallIfNotOwner returns (address) { return _getImplementation(); } /********************** * Internal Functions * **********************/ /** * Sets the implementation address. * @param _implementation New implementation address. */ function _setImplementation(address _implementation) internal { assembly { sstore(IMPLEMENTATION_KEY, _implementation) } } /** * Queries the implementation address. * @return Implementation address. */ function _getImplementation() internal view returns (address) { address implementation; assembly { implementation := sload(IMPLEMENTATION_KEY) } return implementation; } /** * Changes the owner of the proxy contract. * @param _owner New owner of the proxy contract. */ function _setOwner(address _owner) internal { assembly { sstore(OWNER_KEY, _owner) } } /** * Queries the owner of the proxy contract. * @return Owner address. */ function _getOwner() internal view returns (address) { address owner; assembly { owner := sload(OWNER_KEY) } return owner; } /** * Gets the code hash for a given account. * @param _account Address of the account to get a code hash for. * @return Code hash for the account. */ function _getAccountCodeHash(address _account) internal view returns (bytes32) { bytes32 codeHash; assembly { codeHash := extcodehash(_account) } return codeHash; } /** * Performs the proxy call via a delegatecall. */ function _doProxyCall() internal onlyWhenNotPaused { address implementation = _getImplementation(); require(implementation != address(0), "L1ChugSplashProxy: implementation is not set yet"); assembly { // Copy calldata into memory at 0x0....calldatasize. calldatacopy(0x0, 0x0, calldatasize()) // Perform the delegatecall, make sure to pass all available gas. let success := delegatecall(gas(), implementation, 0x0, calldatasize(), 0x0, 0x0) // Copy returndata into memory at 0x0....returndatasize. Note that this *will* // overwrite the calldata that we just copied into memory but that doesn't really // matter because we'll be returning in a second anyway. returndatacopy(0x0, 0x0, returndatasize()) // Success == 0 means a revert. We'll revert too and pass the data up. if iszero(success) { revert(0x0, returndatasize()) } // Otherwise we'll just return and pass the data up. return(0x0, returndatasize()) } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; /** * @title iL1ChugSplashDeployer */ interface iL1ChugSplashDeployer { function isUpgrading() external view returns (bool); }
0x60806040526004361061005a5760003560e01c8063893d20e811610043578063893d20e8146100a45780639b0b0fda146100e2578063aaf10f42146101025761005a565b806313af4035146100645780636c5d4ad014610084575b610062610117565b005b34801561007057600080fd5b5061006261007f366004610792565b6103ba565b34801561009057600080fd5b5061006261009f3660046107fe565b61044b565b3480156100b057600080fd5b506100b9610601565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ee57600080fd5b506100626100fd3660046108cd565b610698565b34801561010e57600080fd5b506100b9610706565b60006101417fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fb7947262000000000000000000000000000000000000000000000000000000001790529051919250600091829173ffffffffffffffffffffffffffffffffffffffff8516916101c3919061092a565b600060405180830381855afa9150503d80600081146101fe576040519150601f19603f3d011682016040523d82523d6000602084013e610203565b606091505b5091509150818015610216575080516020145b156102c8576000818060200190518101906102319190610936565b905080156102c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f4c314368756753706c61736850726f78793a2073797374656d2069732063757260448201527f72656e746c79206265696e67207570677261646564000000000000000000000060648201526084015b60405180910390fd5b505b60006102f27f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b905073ffffffffffffffffffffffffffffffffffffffff8116610397576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f4c314368756753706c61736850726f78793a20696d706c656d656e746174696f60448201527f6e206973206e6f7420736574207965740000000000000000000000000000000060648201526084016102bd565b3660008037600080366000845af43d6000803e806103b4573d6000fd5b503d6000f35b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610413575033155b1561044357610440817fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b50565b610440610117565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806104a4575033155b156104435760006104d37f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b9050803f8251602084012014156104e8575050565b60405160009061051e907f600d380380600d6000396000f30000000000000000000000000000000000000090859060200161094f565b604051602081830303815290604052905060008151602083016000f084516020860120909150813f146105d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f4c314368756753706c61736850726f78793a20636f646520776173206e6f742060448201527f636f72726563746c79206465706c6f7965642e0000000000000000000000000060648201526084016102bd565b6105fb817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b50505050565b600061062b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610662575033155b1561068d57507fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b610695610117565b90565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806106f1575033155b156106fa579055565b610702610117565b5050565b60006107307fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610767575033155b1561068d57507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b6000602082840312156107a457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146107c857600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561081057600080fd5b813567ffffffffffffffff8082111561082857600080fd5b818401915084601f83011261083c57600080fd5b81358181111561084e5761084e6107cf565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715610894576108946107cf565b816040528281528760208487010111156108ad57600080fd5b826020860160208301376000928101602001929092525095945050505050565b600080604083850312156108e057600080fd5b50508035926020909101359150565b6000815160005b8181101561091057602081850181015186830152016108f6565b8181111561091f576000828601525b509290920192915050565b60006107c882846108ef565b60006020828403121561094857600080fd5b5051919050565b7fffffffffffffffffffffffffff00000000000000000000000000000000000000831681526000610983600d8301846108ef565b94935050505056fea2646970667358221220dde189f053dd53b92cedb63aa0b46d4d1bba8c55579e196ac7ca5c1368c5dc8264736f6c63430008090033
[ 2 ]
0xf3d65421245c4c82831849b2f0a0e3f37f4bf50c
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 LVX is StandardToken { function () { throw; } /* Public variables of the token */ string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function LVX( ) { balances[msg.sender] = 200000000000000000000000000; totalSupply = 200000000000000000000000000; name = "LIVE VIDEO XCHANGE"; decimals = 18; symbol = "LVX"; } /* 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; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a723058200928b68f5378313731c0d4830362abdb27955a4be5152ac792e496eb4addbfaa0029
[ 38 ]
0xF3D6Af45C6dFeC43216CC3347Ea91fEfBa0849D1
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ERC20.sol"; import "./Purpose.sol"; contract Dubi is ERC20 { Purpose private immutable _prps; constructor( uint256 initialSupply, address optIn, address purpose, address hodl, address externalAddress1, address externalAddress2, address externalAddress3 ) public ERC20( "Decentralized Universal Basic Income", "DUBI", optIn, hodl, externalAddress1, externalAddress2, externalAddress3 ) { _mintInitialSupply(msg.sender, initialSupply); _prps = Purpose(purpose); } function hodlMint(address to, uint256 amount) public { require(msg.sender == _hodlAddress, "DUBI-2"); _mint(to, amount); } function purposeMint(address to, uint256 amount) public { require(msg.sender == address(_prps), "DUBI-3"); _mint(to, amount); } function _callerIsDeployTimeKnownContract() internal override view returns (bool) { if (msg.sender == address(_prps)) { return true; } return super._callerIsDeployTimeKnownContract(); } //--------------------------------------------------------------- // Fuel //--------------------------------------------------------------- /** * @dev Burns `fuel` from `from`. Can only be called by one of the deploy-time known contracts. */ function burnFuel(address from, TokenFuel memory fuel) public override { require(_callerIsDeployTimeKnownContract(), "DUBI-1"); _burnFuel(from, fuel); } function _burnFuel(address from, TokenFuel memory fuel) private { require(fuel.amount <= MAX_BOOSTER_FUEL, "DUBI-5"); require(from != address(0) && from != msg.sender, "DUBI-6"); if (fuel.tokenAlias == TOKEN_FUEL_ALIAS_DUBI) { // Burn fuel from DUBI UnpackedData memory unpacked = _unpackPackedData(_packedData[from]); require(unpacked.balance >= fuel.amount, "DUBI-7"); unpacked.balance -= fuel.amount; _packedData[from] = _packUnpackedData(unpacked); return; } revert("DUBI-8"); } /** *@dev Burn the fuel of a `boostedSend` */ function _burnBoostedSendFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked ) internal override returns (FuelBurn memory) { FuelBurn memory fuelBurn; if (fuel.dubi > 0) { require(fuel.dubi <= MAX_BOOSTER_FUEL, "DUBI-5"); // From uses his own DUBI to fuel the boost require(unpacked.balance >= fuelBurn.amount, "DUBI-7"); unpacked.balance -= fuel.dubi; fuelBurn.amount = fuel.dubi; fuelBurn.fuelType = FuelType.DUBI; return fuelBurn; } // If the fuel is PRPS, then we have to reach out to the PRPS contract. if (fuel.unlockedPrps > 0) { // Reverts if the requested amount cannot be burned _prps.burnFuel( from, TokenFuel({ tokenAlias: TOKEN_FUEL_ALIAS_UNLOCKED_PRPS, amount: fuel.unlockedPrps }) ); fuelBurn.amount = fuel.unlockedPrps; fuelBurn.fuelType = FuelType.UNLOCKED_PRPS; return fuelBurn; } if (fuel.lockedPrps > 0) { // Reverts if the requested amount cannot be burned _prps.burnFuel( from, TokenFuel({ tokenAlias: TOKEN_FUEL_ALIAS_LOCKED_PRPS, amount: fuel.lockedPrps }) ); fuelBurn.amount = fuel.lockedPrps; fuelBurn.fuelType = FuelType.LOCKED_PRPS; return fuelBurn; } // No fuel at all return fuelBurn; } /** *@dev Burn the fuel of a `boostedBurn` */ function _burnBoostedBurnFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked ) internal override returns (FuelBurn memory) { FuelBurn memory fuelBurn; // If the fuel is DUBI, then we can remove it directly if (fuel.dubi > 0) { require(fuel.dubi <= MAX_BOOSTER_FUEL, "DUBI-5"); require(unpacked.balance >= fuel.dubi, "DUBI-7"); unpacked.balance -= fuel.dubi; fuelBurn.amount = fuel.dubi; fuelBurn.fuelType = FuelType.DUBI; return fuelBurn; } // If the fuel is PRPS, then we have to reach out to the PRPS contract. if (fuel.unlockedPrps > 0) { // Reverts if the requested amount cannot be burned _prps.burnFuel( from, TokenFuel({ tokenAlias: TOKEN_FUEL_ALIAS_UNLOCKED_PRPS, amount: fuel.unlockedPrps }) ); fuelBurn.amount = fuel.unlockedPrps; fuelBurn.fuelType = FuelType.UNLOCKED_PRPS; return fuelBurn; } if (fuel.lockedPrps > 0) { // Reverts if the requested amount cannot be burned _prps.burnFuel( from, TokenFuel({ tokenAlias: TOKEN_FUEL_ALIAS_LOCKED_PRPS, amount: fuel.lockedPrps }) ); // No direct fuel, but we still return a indirect fuel so that it can be added // to the burn event. fuelBurn.amount = fuel.lockedPrps; fuelBurn.fuelType = FuelType.LOCKED_PRPS; return fuelBurn; } // DUBI has no intrinsic fuel if (fuel.intrinsicFuel > 0) { revert("DUBI-8"); } // No fuel at all return fuelBurn; } //--------------------------------------------------------------- // Pending ops //--------------------------------------------------------------- function _getHasherContracts() internal override returns (address[] memory) { address[] memory hashers = new address[](5); hashers[0] = address(this); hashers[1] = address(_prps); hashers[2] = _hodlAddress; hashers[3] = _externalAddress1; hashers[4] = _externalAddress2; return hashers; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/introspection/IERC1820Registry.sol"; import "./IBoostableERC20.sol"; import "./BoostableERC20.sol"; /** * @dev This is a heavily modified fork of @openzeppelin/contracts/token/ERC20/ERC20.sol (3.1.0) */ abstract contract ERC20 is IERC20, IBoostableERC20, BoostableERC20, Ownable { using SafeMath for uint256; // NOTE: In contrary to the Transfer event, the Burned event always // emits the amount including the burned fuel if any. // The amount is stored in the lower 96 bits of `amountAndFuel`, // followed by 3 bits to encode the type of fuel used and finally // another 96 bits for the fuel amount. // // 0 96 99 195 256 // amount fuelType fuelAmount padding // event Burned(uint256 amountAndFuel, bytes data); enum FuelType {NONE, UNLOCKED_PRPS, LOCKED_PRPS, DUBI, AUTO_MINTED_DUBI} struct FuelBurn { FuelType fuelType; uint96 amount; } uint256 private _totalSupply; string private _name; string private _symbol; address internal immutable _hodlAddress; address internal immutable _externalAddress1; address internal immutable _externalAddress2; address internal immutable _externalAddress3; IERC1820Registry internal constant _ERC1820_REGISTRY = IERC1820Registry( 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24 ); // Mapping of address to packed data. // For efficiency reasons the token balance is a packed uint96 alongside // other data. The packed data has the following layout: // // MSB uint256 LSB // uint64 nonce | uint96 hodlBalance | uint96 balance // // balance: the balance of a token holder that can be transferred freely // hodlBalance: the balance of a token holder that is hodled // nonce: a sequential number used for booster replay protection // // Only PRPS utilizes `hodlBalance`. For DUBI it is always 0. // mapping(address => uint256) internal _packedData; struct UnpackedData { uint96 balance; uint96 hodlBalance; uint64 nonce; } function _unpackPackedData(uint256 packedData) internal pure returns (UnpackedData memory) { UnpackedData memory unpacked; // 1) Read balance from the first 96 bits unpacked.balance = uint96(packedData); // 2) Read hodlBalance from the next 96 bits unpacked.hodlBalance = uint96(packedData >> 96); // 3) Read nonce from the next 64 bits unpacked.nonce = uint64(packedData >> (96 + 96)); return unpacked; } function _packUnpackedData(UnpackedData memory unpacked) internal pure returns (uint256) { uint256 packedData; // 1) Write balance to the first 96 bits packedData |= unpacked.balance; // 2) Write hodlBalance to the the next 96 bits packedData |= uint256(unpacked.hodlBalance) << 96; // 3) Write nonce to the next 64 bits packedData |= uint256(unpacked.nonce) << (96 + 96); return packedData; } // ERC20-allowances mapping(address => mapping(address => uint256)) private _allowances; //--------------------------------------------------------------- // Pending state for non-boosted operations while opted-in //--------------------------------------------------------------- uint8 internal constant OP_TYPE_SEND = BOOST_TAG_SEND; uint8 internal constant OP_TYPE_BURN = BOOST_TAG_BURN; struct PendingTransfer { // NOTE: For efficiency reasons balances are stored in a uint96 which is sufficient // since we only use 18 decimals. // // Two amounts are associated with a pending transfer, to allow deriving contracts // to store extra information. // // E.g. PRPS makes use of this by encoding the pending locked PRPS in the // `occupiedAmount` field. // address spender; uint96 transferAmount; address to; uint96 occupiedAmount; bytes data; } // A mapping of hash(user, opId) to pending transfers. Pending burns are also considered regular transfers. mapping(bytes32 => PendingTransfer) private _pendingTransfers; //--------------------------------------------------------------- constructor( string memory name, string memory symbol, address optIn, address hodl, address externalAddress1, address externalAddress2, address externalAddress3 ) public Ownable() BoostableERC20(optIn) { _name = name; _symbol = symbol; _hodlAddress = hodl; _externalAddress1 = externalAddress1; _externalAddress2 = externalAddress2; _externalAddress3 = externalAddress3; // register interfaces _ERC1820_REGISTRY.setInterfaceImplementer( address(this), keccak256("BoostableERC20Token"), address(this) ); _ERC1820_REGISTRY.setInterfaceImplementer( address(this), keccak256("ERC20Token"), address(this) ); } /** * @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. */ function decimals() public pure returns (uint8) { return 18; } /** * @dev Returns the current nonce of `account` */ function getNonce(address account) external override view returns (uint64) { UnpackedData memory unpacked = _unpackPackedData(_packedData[account]); return unpacked.nonce; } /** * @dev Returns the total supply */ function totalSupply() external override(IBoostableERC20, IERC20) view returns (uint256) { return _totalSupply; } /** * @dev Returns the amount of tokens owned by an account (`tokenHolder`). */ function balanceOf(address tokenHolder) public override(IBoostableERC20, IERC20) view returns (uint256) { // Return the balance of the holder that is not hodled (i.e. first 96 bits of the packeData) return uint96(_packedData[tokenHolder]); } /** * @dev Returns the unpacked data struct of `tokenHolder` */ function unpackedDataOf(address tokenHolder) public view returns (UnpackedData memory) { return _unpackPackedData(_packedData[tokenHolder]); } /** * @dev Mints `amount` new tokens for `to`. * * To make things more efficient, the total supply is optionally packed into the passed * amount where the first 96 bits are used for the actual amount and the following 96 bits * for the total supply. * */ function mint(address to, uint256 amount) public onlyOwner { _mint(to, amount); } function _mintInitialSupply(address to, uint256 amount) internal { // _mint does not update the totalSupply by default, unless the second 96 bits // passed are non-zero - in which case the non-zero value becomes the new total supply. // So in order to get the correct initial supply, we have to mirror the lower 96 bits // to the following 96 bits. amount = amount | (amount << 96); _mint(to, amount); } function _mint(address to, uint256 amount) internal { require(to != address(0), "ERC20-1"); // The actual amount to mint (=lower 96 bits) uint96 amountToMint = uint96(amount); // The new total supply, which may be 0 in which case no update is performed. uint96 updatedTotalSupply = uint96(amount >> 96); // Update state variables if (updatedTotalSupply > 0) { _totalSupply = updatedTotalSupply; } // Update packed data and check for uint96 overflow UnpackedData memory unpacked = _unpackPackedData(_packedData[to]); uint96 updatedBalance = unpacked.balance + amountToMint; // The overflow check also takes the hodlBalance into account require( updatedBalance + unpacked.hodlBalance >= unpacked.balance, "ERC20-2" ); unpacked.balance = updatedBalance; _packedData[to] = _packUnpackedData(unpacked); emit Transfer(address(0), to, amountToMint); } /** * @dev Transfer `amount` from msg.sender to `recipient` */ function transfer(address recipient, uint256 amount) public override(IBoostableERC20, IERC20) returns (bool) { _assertSenderRecipient(msg.sender, recipient); // Never create a pending transfer if msg.sender is a deploy-time known contract if (!_callerIsDeployTimeKnownContract()) { // Create pending transfer if sender is opted-in and the permaboost is active address from = msg.sender; IOptIn.OptInStatus memory optInStatus = getOptInStatus(from); if (optInStatus.isOptedIn && optInStatus.permaBoostActive) { _createPendingTransfer({ opType: OP_TYPE_SEND, spender: msg.sender, from: msg.sender, to: recipient, amount: amount, data: "", optInStatus: optInStatus }); return true; } } _move({from: msg.sender, to: recipient, amount: amount}); return true; } /** * @dev Burns `amount` of msg.sender. * * Also emits a {IERC20-Transfer} event for ERC20 compatibility. */ function burn(uint256 amount, bytes memory data) public { // Create pending burn if sender is opted-in and the permaboost is active IOptIn.OptInStatus memory optInStatus = getOptInStatus(msg.sender); if (optInStatus.isOptedIn && optInStatus.permaBoostActive) { _createPendingTransfer({ opType: OP_TYPE_BURN, spender: msg.sender, from: msg.sender, to: address(0), amount: amount, data: data, optInStatus: optInStatus }); return; } _burn({ from: msg.sender, amount: amount, data: data, incrementNonce: false }); } /** * @dev Moves `amount` tokens from `sender` to `recipient`. * * Can only be used by deploy-time known contracts. * * IBoostableERC20 extension */ function boostedTransferFrom( address sender, address recipient, uint256 amount, bytes calldata data ) public override returns (bool) { _assertSenderRecipient(sender, recipient); IOptIn.OptInStatus memory optInStatus = getOptInStatus(sender); // Only transfer if `sender` is a deploy-time known contract, otherwise // revert. require( _isDeployTimeKnownContractAndCanTransfer( sender, recipient, amount, optInStatus, data ), "ERC20-17" ); _move({from: sender, to: recipient, amount: amount}); return true; } function _isDeployTimeKnownContractAndCanTransfer( address sender, address recipient, uint256 amount, IOptIn.OptInStatus memory optInStatus, bytes memory data ) private view returns (bool) { // If the caller not a deploy-time known contract, the transfer is not allowed if (!_callerIsDeployTimeKnownContract()) { return false; } if (msg.sender != _externalAddress3) { return true; } // _externalAddress3 passes a flag via `data` that indicates whether it is a boosted transaction // or not. uint8 isBoostedBits; assembly { // Load flag using a 1-byte offset, because `mload` always reads // 32-bytes at once and the first 32 bytes of `data` contain it's length. isBoostedBits := mload(add(data, 0x01)) } // Reading into a 'bool' directly doesn't work for some reason if (isBoostedBits & 1 == 1) { return true; } // If the latter, then _externalAddress3 can only transfer the funds if either: // - the permaboost is not active // - `sender` is not opted-in to begin with // // If `sender` is opted-in and the permaboost is active, _externalAddress3 cannot // take funds, except when boosted. Here the booster trusts _externalAddress3, since it already // verifies that `sender` provided a valid signature. // // This is special to _externalAddress3, other deploy-time known contracts do not make use of `data`. if (optInStatus.permaBoostActive && optInStatus.isOptedIn) { return false; } return true; } /** * @dev Verify the booster payload against the nonce that is stored in the packed data of an account. * The increment happens outside of this function, when the balance is updated. */ function _verifyNonce(BoosterPayload memory payload, uint64 currentNonce) internal pure { require(currentNonce == payload.nonce - 1, "ERC20-5"); } //--------------------------------------------------------------- // Boosted functions //--------------------------------------------------------------- /** * @dev Perform multiple `boostedSend` calls in a single transaction. * * NOTE: Booster extension */ function boostedSendBatch( BoostedSend[] memory sends, Signature[] memory signatures ) external { require( sends.length > 0 && sends.length == signatures.length, "ERC20-6" ); for (uint256 i = 0; i < sends.length; i++) { boostedSend(sends[i], signatures[i]); } } /** * @dev Perform multiple `boostedBurn` calls in a single transaction. * * NOTE: Booster extension */ function boostedBurnBatch( BoostedBurn[] memory burns, Signature[] memory signatures ) external { require( burns.length > 0 && burns.length == signatures.length, "ERC20-6" ); for (uint256 i = 0; i < burns.length; i++) { boostedBurn(burns[i], signatures[i]); } } /** * @dev Send `amount` tokens from `sender` to recipient`. * The `sender` must be opted-in and the `msg.sender` must be a trusted booster. * * NOTE: Booster extension */ function boostedSend(BoostedSend memory send, Signature memory signature) public { address from = send.sender; address to = send.recipient; UnpackedData memory unpackedFrom = _unpackPackedData(_packedData[from]); UnpackedData memory unpackedTo = _unpackPackedData(_packedData[to]); // We verify the nonce separately, since it's stored next to the balance _verifyNonce(send.boosterPayload, unpackedFrom.nonce); _verifyBoostWithoutNonce( send.sender, hashBoostedSend(send, msg.sender), send.boosterPayload, signature ); FuelBurn memory fuelBurn = _burnBoostedSendFuel( from, send.fuel, unpackedFrom ); _moveUnpacked({ from: send.sender, unpackedFrom: unpackedFrom, to: send.recipient, unpackedTo: unpackedTo, amount: send.amount, fuelBurn: fuelBurn, incrementNonce: true }); } /** * @dev Burn the fuel of a `boostedSend`. Returns a `FuelBurn` struct containing information about the burn. */ function _burnBoostedSendFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked ) internal virtual returns (FuelBurn memory); /** * @dev Burn `amount` tokens from `account`. * The `account` must be opted-in and the `msg.sender` must be a trusted booster. * * NOTE: Booster extension */ function boostedBurn( BoostedBurn memory message, // A signature, that is compared against the function payload and only accepted if signed by 'sender' Signature memory signature ) public { address from = message.account; UnpackedData memory unpacked = _unpackPackedData(_packedData[from]); // We verify the nonce separately, since it's stored next to the balance _verifyNonce(message.boosterPayload, unpacked.nonce); _verifyBoostWithoutNonce( message.account, hashBoostedBurn(message, msg.sender), message.boosterPayload, signature ); FuelBurn memory fuelBurn = _burnBoostedBurnFuel( from, message.fuel, unpacked ); _burnUnpacked({ from: message.account, unpacked: unpacked, amount: message.amount, data: message.data, incrementNonce: true, fuelBurn: fuelBurn }); } /** * @dev Burn the fuel of a `boostedSend`. Returns a `FuelBurn` struct containing information about the burn. */ function _burnBoostedBurnFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked ) internal virtual returns (FuelBurn memory); function burnFuel(address from, TokenFuel memory fuel) external virtual override {} //--------------------------------------------------------------- /** * @dev Get the allowance of `spender` for `holder` */ function allowance(address holder, address spender) public override(IBoostableERC20, IERC20) view returns (uint256) { return _allowances[holder][spender]; } /** * @dev Increase the allowance of `spender` by `value` for msg.sender */ function approve(address spender, uint256 value) public override(IBoostableERC20, IERC20) returns (bool) { address holder = msg.sender; _assertSenderRecipient(holder, spender); _approve(holder, spender, value); 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) { _assertSenderRecipient(msg.sender, spender); _approve( msg.sender, spender, _allowances[msg.sender][spender].add(addedValue) ); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _assertSenderRecipient(msg.sender, spender); _approve( msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20-18") ); return true; } /** * @dev Transfer `amount` from `holder` to `recipient`. * * `msg.sender` requires an allowance >= `amount` of `holder`. */ function transferFrom( address holder, address recipient, uint256 amount ) public override(IBoostableERC20, IERC20) returns (bool) { _assertSenderRecipient(holder, recipient); address spender = msg.sender; // Create pending transfer if the token holder is opted-in and the permaboost is active IOptIn.OptInStatus memory optInStatus = getOptInStatus(holder); if (optInStatus.isOptedIn && optInStatus.permaBoostActive) { // Ignore allowances if holder is opted-in require(holder == spender, "ERC20-7"); _createPendingTransfer({ opType: OP_TYPE_SEND, spender: spender, from: holder, to: recipient, amount: amount, data: "", optInStatus: optInStatus }); return true; } // Not opted-in, but we still need to check approval of the given spender _approve( holder, spender, _allowances[holder][spender].sub(amount, "ERC20-4") ); _move({from: holder, to: recipient, amount: amount}); return true; } /** * @dev Burn tokens * @param from address token holder address * @param amount uint256 amount of tokens to burn * @param data bytes extra information provided by the token holder * @param incrementNonce whether to increment the nonce or not - only true for boosted burns */ function _burn( address from, uint256 amount, bytes memory data, bool incrementNonce ) internal virtual { require(from != address(0), "ERC20-8"); UnpackedData memory unpacked = _unpackPackedData(_packedData[from]); // Empty fuel burn FuelBurn memory fuelBurn; _burnUnpacked({ from: from, unpacked: unpacked, amount: amount, data: data, incrementNonce: incrementNonce, fuelBurn: fuelBurn }); } function _burnUnpacked( address from, UnpackedData memory unpacked, uint256 amount, bytes memory data, bool incrementNonce, FuelBurn memory fuelBurn ) internal { // _beforeBurn allows deriving contracts to run additional logic and affect the amount // that is actually getting burned. E.g. when burning PRPS, a portion of it might be taken // from the `hodlBalance`. Thus the returned `burnAmount` overrides `amount` and will be // subtracted from the actual `balance`. uint96 actualBurnAmount = _beforeBurn({ from: from, unpacked: unpacked, transferAmount: uint96(amount), occupiedAmount: 0, createdAt: uint32(block.timestamp), fuelBurn: fuelBurn, finalizing: false }); // Update to new balance if (incrementNonce) { // The nonce uses 64 bits, so a overflow is pretty much impossible // via increments of 1. unpacked.nonce++; } if (actualBurnAmount > 0) { require(unpacked.balance >= actualBurnAmount, "ERC20-9"); unpacked.balance -= actualBurnAmount; } // Update packed data by writing to storage _packedData[from] = _packUnpackedData(unpacked); // Total supply can be updated in batches elsewhere, shaving off another >5k gas. // _totalSupply = _totalSupply.sub(amount); // The `Burned` event is emitted with the total amount that got burned. // Furthermore, the fuel used is encoded in the upper bits. uint256 amountAndFuel; // Set first 96 bits to amount amountAndFuel |= uint96(amount); // Set next 3 bits to fuel type uint8 fuelType = uint8(fuelBurn.fuelType); amountAndFuel |= uint256(fuelType) << 96; // Set next 96 bits to fuel amount amountAndFuel |= uint256(fuelBurn.amount) << (96 + 3); emit Burned(amountAndFuel, data); // We emit a transfer event with the actual burn amount excluding burned `hodlBalance`. emit Transfer(from, address(0), actualBurnAmount); } /** * @dev Allow deriving contracts to prepare a burn. By default it behaves like an identity function * and just returns the amount passed in. */ function _beforeBurn( address from, UnpackedData memory unpacked, uint96 transferAmount, uint96 occupiedAmount, uint32 createdAt, FuelBurn memory fuelBurn, bool finalizing ) internal virtual returns (uint96) { return transferAmount; } function _move( address from, address to, uint256 amount ) internal { UnpackedData memory unpackedFrom = _unpackPackedData(_packedData[from]); UnpackedData memory unpackedTo = _unpackPackedData(_packedData[to]); // Empty fuel burn FuelBurn memory fuelBurn; _moveUnpacked({ from: from, unpackedFrom: unpackedFrom, to: to, unpackedTo: unpackedTo, amount: amount, incrementNonce: false, fuelBurn: fuelBurn }); } function _moveUnpacked( address from, UnpackedData memory unpackedFrom, address to, UnpackedData memory unpackedTo, uint256 amount, bool incrementNonce, FuelBurn memory fuelBurn ) internal { require(from != to, "ERC20-19"); // Increment nonce of sender if it's a boosted send if (incrementNonce) { // The nonce uses 64 bits, so a overflow is pretty much impossible // via increments of 1. unpackedFrom.nonce++; } // Check if sender has enough tokens uint96 transferAmount = uint96(amount); require(unpackedFrom.balance >= transferAmount, "ERC20-10"); // Subtract transfer amount from sender balance unpackedFrom.balance -= transferAmount; // Check that recipient balance doesn't overflow uint96 updatedRecipientBalance = unpackedTo.balance + transferAmount; require(updatedRecipientBalance >= unpackedTo.balance, "ERC20-12"); unpackedTo.balance = updatedRecipientBalance; _packedData[from] = _packUnpackedData(unpackedFrom); _packedData[to] = _packUnpackedData(unpackedTo); // The transfer amount does not include any used fuel emit Transfer(from, to, transferAmount); } /** * @dev See {ERC20-_approve}. */ function _approve( address holder, address spender, uint256 value ) internal { _allowances[holder][spender] = value; emit Approval(holder, spender, value); } function _assertSenderRecipient(address sender, address recipient) private pure { require(sender != address(0) && recipient != address(0), "ERC20-13"); } /** * @dev Checks whether msg.sender is a deploy-time known contract or not. */ function _callerIsDeployTimeKnownContract() internal virtual view returns (bool) { if (msg.sender == _hodlAddress) { return true; } if (msg.sender == _externalAddress1) { return true; } if (msg.sender == _externalAddress2) { return true; } if (msg.sender == _externalAddress3) { return true; } return false; } //--------------------------------------------------------------- // Pending ops //--------------------------------------------------------------- /** * @dev Create a pending transfer */ function _createPendingTransfer( uint8 opType, address spender, address from, address to, uint256 amount, bytes memory data, IOptIn.OptInStatus memory optInStatus ) private { OpHandle memory opHandle = _createNewOpHandle( optInStatus, from, opType ); PendingTransfer memory pendingTransfer = _createPendingTransferInternal( opHandle, spender, from, to, amount, data ); _pendingTransfers[_getOpKey(from, opHandle.opId)] = pendingTransfer; // Emit PendingOp event emit PendingOp(from, opHandle.opId, opHandle.opType); } /** * @dev Create a pending transfer by moving the funds of `spender` to this contract. * Deriving contracts may override this function. */ function _createPendingTransferInternal( OpHandle memory opHandle, address spender, address from, address to, uint256 amount, bytes memory data ) internal virtual returns (PendingTransfer memory) { // Move funds into this contract // Reverts if `from` has less than `amount` tokens. _move({from: from, to: address(this), amount: amount}); // Create op PendingTransfer memory pendingTransfer = PendingTransfer({ transferAmount: uint96(amount), spender: spender, occupiedAmount: 0, to: to, data: data }); return pendingTransfer; } /** * @dev Finalize a pending op */ function finalizePendingOp(address user, OpHandle memory opHandle) public { uint8 opType = opHandle.opType; // Assert that the caller (msg.sender) is allowed to finalize the given op uint32 createdAt = uint32(_assertCanFinalize(user, opHandle)); // Reverts if opId doesn't exist PendingTransfer storage pendingTransfer = _safeGetPendingTransfer( user, opHandle.opId ); // Cleanup // NOTE: We do not delete the pending transfer struct, because it only makes it // more expensive since we already hit the gas refund limit. // // delete _pendingTransfers[_getOpKey(user, opHandle.opId)]; // // The difference is ~13k gas. // // Deleting the op handle is enough to invalidate an opId forever: _deleteOpHandle(user, opHandle); // Call op type specific finalize if (opType == OP_TYPE_SEND) { _finalizeTransferOp(pendingTransfer, user, createdAt); } else if (opType == OP_TYPE_BURN) { _finalizePendingBurn(pendingTransfer, user, createdAt); } else { revert("ERC20-15"); } // Emit event emit FinalizedOp(user, opHandle.opId, opType); } /** * @dev Finalize a pending transfer */ function _finalizeTransferOp( PendingTransfer storage pendingTransfer, address from, uint32 createdAt ) private { address to = pendingTransfer.to; uint96 transferAmount = pendingTransfer.transferAmount; address _this = address(this); UnpackedData memory unpackedThis = _unpackPackedData( _packedData[_this] ); UnpackedData memory unpackedTo = _unpackPackedData(_packedData[to]); // Check that sender balance does not overflow require(unpackedThis.balance >= transferAmount, "ERC20-2"); unpackedThis.balance -= transferAmount; // Check that recipient doesn't overflow uint96 updatedBalanceRecipient = unpackedTo.balance + transferAmount; require(updatedBalanceRecipient >= unpackedTo.balance, "ERC20-2"); unpackedTo.balance = updatedBalanceRecipient; _packedData[_this] = _packUnpackedData(unpackedThis); _packedData[to] = _packUnpackedData(unpackedTo); // Transfer event is emitted with original sender emit Transfer(from, to, transferAmount); } /** * @dev Finalize a pending burn */ function _finalizePendingBurn( PendingTransfer storage pendingTransfer, address from, uint32 createdAt ) private { uint96 transferAmount = pendingTransfer.transferAmount; // We pass the packedData of `from` to `_beforeBurn`, because it PRPS needs to update // the `hodlBalance` which is NOT on the contract's own packedData. UnpackedData memory unpackedFrom = _unpackPackedData(_packedData[from]); // Empty fuel burn FuelBurn memory fuelBurn; uint96 burnAmountExcludingLockedPrps = _beforeBurn({ from: from, unpacked: unpackedFrom, transferAmount: transferAmount, occupiedAmount: pendingTransfer.occupiedAmount, createdAt: createdAt, fuelBurn: fuelBurn, finalizing: true }); // Update to new balance // NOTE: We change the balance of this contract, because that's where // the pending PRPS went to. address _this = address(this); UnpackedData memory unpackedOfContract = _unpackPackedData( _packedData[_this] ); require( unpackedOfContract.balance >= burnAmountExcludingLockedPrps, "ERC20-2" ); unpackedOfContract.balance -= burnAmountExcludingLockedPrps; _packedData[_this] = _packUnpackedData(unpackedOfContract); _packedData[from] = _packUnpackedData(unpackedFrom); // Furthermore, total supply can be updated elsewhere, shaving off another >5k gas. // _totalSupply = _totalSupply.sub(amount); // Emit events using the same `transferAmount` instead of what `_beforeBurn` // returned which is only used for updating the balance correctly. emit Burned(transferAmount, pendingTransfer.data); emit Transfer(from, address(0), transferAmount); } /** * @dev Revert a pending operation. * * Only the opted-in booster can revert a transaction if it provides a signed and still valid booster message * from the original sender. */ function revertPendingOp( address user, OpHandle memory opHandle, bytes memory boosterMessage, Signature memory signature ) public { // Prepare revert, including permission check and prevents reentrancy for same opHandle. _prepareOpRevert({ user: user, opHandle: opHandle, boosterMessage: boosterMessage, signature: signature }); // Now perform the actual revert of the pending op _revertPendingOp(user, opHandle.opType, opHandle.opId); } /** * @dev Revert a pending transfer */ function _revertPendingOp( address user, uint8 opType, uint64 opId ) private { PendingTransfer storage pendingTransfer = _safeGetPendingTransfer( user, opId ); uint96 transferAmount = pendingTransfer.transferAmount; uint96 occupiedAmount = pendingTransfer.occupiedAmount; // Move funds from this contract back to the original sender. Transfers and burns // are reverted the same way. We only transfer back the `transferAmount` - that is the amount // that actually got moved into this contract. The occupied amount is released during `onRevertPendingOp` // by the deriving contract. _move({from: address(this), to: user, amount: transferAmount}); // Call hook to allow deriving contracts to perform additional cleanup _onRevertPendingOp(user, opType, opId, transferAmount, occupiedAmount); // NOTE: we do not clean up the ops mapping, because we already hit the // gas refund limit. // delete _pendingTransfers[_getOpKey(user, opHandle.opId)]; // Emit event emit RevertedOp(user, opId, opType); } /** * @dev Hook that is called during revert of a pending transfer. * Allows deriving contracts to perform additional cleanup. */ function _onRevertPendingOp( address user, uint8 opType, uint64 opId, uint96 transferAmount, uint96 occupiedAmount ) internal virtual {} /** * @dev Safely get a pending transfer. Reverts if it doesn't exist. */ function _safeGetPendingTransfer(address user, uint64 opId) private view returns (PendingTransfer storage) { PendingTransfer storage pendingTransfer = _pendingTransfers[_getOpKey( user, opId )]; require(pendingTransfer.spender != address(0), "ERC20-16"); return pendingTransfer; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./ERC20.sol"; import "./Dubi.sol"; import "./IHodl.sol"; import "./MintMath.sol"; contract Purpose is ERC20 { // The DUBI contract, required for auto-minting DUBI on burn. Dubi private immutable _dubi; // The HODL contract, required for burning locked PRPS. IHodl private immutable _hodl; modifier onlyHodl() { require(msg.sender == _hodlAddress, "PRPS-1"); _; } constructor( uint256 initialSupply, address optIn, address dubi, address hodl, address externalAddress1, address externalAddress2, address externalAddress3 ) public ERC20( "Purpose", "PRPS", optIn, hodl, externalAddress1, externalAddress2, externalAddress3 ) { _dubi = Dubi(dubi); _hodl = IHodl(hodl); _mintInitialSupply(msg.sender, initialSupply); } /** * @dev Returns the address of the {HODL} contract used for burning locked PRPS. */ function hodl() external view returns (address) { return address(_hodl); } /** * @dev Returns the hodl balance of the given `tokenHolder` */ function hodlBalanceOf(address tokenHolder) public view returns (uint256) { // The hodl balance follows after the first 96 bits in the packed data. return uint96(_packedData[tokenHolder] >> 96); } /** * @dev Transfer `amount` PRPS from `from` to the Hodl contract. * * This can only be called by the Hodl contract. */ function hodlTransfer(address from, uint96 amount) external onlyHodl { _move(from, address(_hodl), amount); } /** * @dev Increase the hodl balance of `account` by `hodlAmount`. This is * only used as part of the migration. */ function migrateHodlBalance(address account, uint96 hodlAmount) external onlyHodl { UnpackedData memory unpacked = _unpackPackedData(_packedData[account]); unpacked.hodlBalance += hodlAmount; _packedData[account] = _packUnpackedData(unpacked); } /** * @dev Increase the hodl balance of `to` by moving `amount` PRPS from `from`'s balance. * * This can only be called by the Hodl contract. */ function increaseHodlBalance( address from, address to, uint96 amount ) external onlyHodl { UnpackedData memory unpackedDataFrom = _unpackPackedData( _packedData[from] ); UnpackedData memory unpackedDataTo; // We only need to unpack twice if from != to if (from != to) { unpackedDataTo = _unpackPackedData(_packedData[to]); } else { unpackedDataTo = unpackedDataFrom; } // `from` must have enough balance require(unpackedDataFrom.balance >= amount, "PRPS-3"); // Subtract balance from `from` unpackedDataFrom.balance -= amount; // Add to `hodlBalance` from `to` unpackedDataTo.hodlBalance += amount; // We only need to pack twice if from != to if (from != to) { _packedData[to] = _packUnpackedData(unpackedDataTo); } _packedData[from] = _packUnpackedData(unpackedDataFrom); } /** * @dev Decrease the hodl balance of `from` by `hodlAmount` and increase * the regular balance by `refundAmount. * * `refundAmount` might be less than `hodlAmount`. * * E.g. when burning fuel in locked PRPS * * This can only be called by the Hodl contract. */ function decreaseHodlBalance( address from, uint96 hodlAmount, uint96 refundAmount ) external onlyHodl { require(hodlAmount >= refundAmount, "PRPS-4"); UnpackedData memory unpackedDataFrom = _unpackPackedData( _packedData[from] ); // `from` must have enough balance require(unpackedDataFrom.hodlBalance >= hodlAmount, "PRPS-5"); // Subtract amount from hodl balance unpackedDataFrom.hodlBalance -= hodlAmount; if (refundAmount > 0) { // Add amount to balance unpackedDataFrom.balance += refundAmount; } // Write to storage _packedData[from] = _packUnpackedData(unpackedDataFrom); } /** * @dev Revert the hodl balance change caused by `from` on `to`. * * E.g. when reverting a pending hodl. * * This can only be called by the Hodl contract. */ function revertHodlBalance( address from, address to, uint96 amount ) external onlyHodl { UnpackedData memory unpackedDataFrom = _unpackPackedData( _packedData[from] ); UnpackedData memory unpackedDataTo; // We only need to unpack twice if from != to if (from != to) { unpackedDataTo = _unpackPackedData(_packedData[to]); } else { unpackedDataTo = unpackedDataFrom; } // `to` must have enough hodl balance require(unpackedDataTo.hodlBalance >= amount, "PRPS-5"); // Subtract hodl balance from `to` unpackedDataTo.hodlBalance -= amount; // Add to `balance` from `from` unpackedDataFrom.balance += amount; // We only need to pack twice if from != to if (from != to) { _packedData[to] = _packUnpackedData(unpackedDataTo); } _packedData[from] = _packUnpackedData(unpackedDataFrom); } /** * @dev Mint DUBI when burning PRPS * @param from address token holder address * @param transferAmount amount of tokens to burn * @param occupiedAmount amount of tokens that are occupied * @param createdAt equal to block.timestamp if not finalizing a pending op, otherwise * it corresponds to op.createdAt * @param finalizing boolean indicating whether this is a finalizing transaction or not. Changes * how the `amount` is interpreted. * * When burning PRPS, we first try to burn unlocked PRPS. * If burning an amount that exceeds the unlocked PRPS of `from`, we attempt to burn the * difference from locked PRPS. * * If the desired `amount` cannot be filled by taking locked and unlocked PRPS into account, * this function reverts. * * Burning locked PRPS means reducing the `hodlBalance` while burning unlocked PRPS means reducing * the regular `balance`. * * This function returns the actual unlocked PRPS that needs to be removed from `balance`. * */ function _beforeBurn( address from, UnpackedData memory unpacked, uint96 transferAmount, uint96 occupiedAmount, uint32 createdAt, FuelBurn memory fuelBurn, bool finalizing ) internal override returns (uint96) { uint96 totalDubiToMint; uint96 lockedPrpsToBurn; uint96 burnableUnlockedPrps; // Depending on whether this is a finalizing burn or not, // the amount of locked/unlocked PRPS is determined differently. if (finalizing) { // For a finalizing burn, we use the occupied amount, since we already know how much // locked PRPS we are going to burn. This amount represents the `pendingLockedPrps` // on the hodl items. lockedPrpsToBurn = occupiedAmount; // Since `transferAmount` is the total amount of PRPS getting burned, we need to subtract // the `occupiedAmount` to get the actual amount of unlocked PRPS. // Sanity check assert(transferAmount >= occupiedAmount); transferAmount -= occupiedAmount; // Set the unlocked PRPS to burn to the updated `transferAmount` burnableUnlockedPrps = transferAmount; } else { // For a direct burn, we start off with the full amounts, since we don't know the exact // amounts initially. lockedPrpsToBurn = transferAmount; burnableUnlockedPrps = unpacked.balance; } // 1) Try to burn unlocked PRPS if (burnableUnlockedPrps > 0) { // Nice, we can burn unlocked PRPS // Catch underflow i.e. don't burn more than we need to if (burnableUnlockedPrps > transferAmount) { burnableUnlockedPrps = transferAmount; } // Calculate DUBI to mint based on unlocked PRPS we can burn totalDubiToMint = MintMath.calculateDubiToMintMax( burnableUnlockedPrps ); // Subtract the amount of burned unlocked PRPS from the locked PRPS we // need to burn if this is NOT a finalizing burn, because in that case we // already have the exact amount locked PRPS we want to burn. if (!finalizing) { lockedPrpsToBurn -= burnableUnlockedPrps; } } // 2) Burn locked PRPS if there's not enough unlocked PRPS // Burn an additional amount of locked PRPS equal to the fuel if any if (fuelBurn.fuelType == FuelType.LOCKED_PRPS) { // The `burnFromLockedPrps` call will fail, if not enough PRPS can be burned. lockedPrpsToBurn += fuelBurn.amount; } if (lockedPrpsToBurn > 0) { uint96 dubiToMintFromLockedPrps = _burnFromLockedPrps({ from: from, unpacked: unpacked, lockedPrpsToBurn: lockedPrpsToBurn, createdAt: createdAt, finalizing: finalizing }); // We check 'greater than or equal' because it's possible to mint 0 new DUBI // e.g. when called right after a hodl where not enough time passed to generate new DUBI. uint96 dubiToMint = totalDubiToMint + dubiToMintFromLockedPrps; require(dubiToMint >= totalDubiToMint, "PRPS-6"); totalDubiToMint = dubiToMint; } else { // Sanity check for finalizes that don't touch locked PRPS assert(occupiedAmount == 0); } // Burn minted DUBI equal to the fuel if any if (fuelBurn.fuelType == FuelType.AUTO_MINTED_DUBI) { require(totalDubiToMint >= fuelBurn.amount, "PRPS-7"); totalDubiToMint -= fuelBurn.amount; } // Mint DUBI taking differences between burned locked/unlocked into account if (totalDubiToMint > 0) { _dubi.purposeMint(from, totalDubiToMint); } return burnableUnlockedPrps; } function _burnFromLockedPrps( address from, UnpackedData memory unpacked, uint96 lockedPrpsToBurn, uint32 createdAt, bool finalizing ) private returns (uint96) { // Reverts if the exact amount needed cannot be burned uint96 dubiToMintFromLockedPrps = _hodl.burnLockedPrps({ from: from, amount: lockedPrpsToBurn, dubiMintTimestamp: createdAt, burnPendingLockedPrps: finalizing }); require(unpacked.hodlBalance >= lockedPrpsToBurn, "PRPS-8"); unpacked.hodlBalance -= lockedPrpsToBurn; return dubiToMintFromLockedPrps; } function _callerIsDeployTimeKnownContract() internal override view returns (bool) { if (msg.sender == address(_dubi)) { return true; } return super._callerIsDeployTimeKnownContract(); } //--------------------------------------------------------------- // Fuel //--------------------------------------------------------------- /** * @dev Burns `fuel` from `from`. Can only be called by one of the deploy-time known contracts. */ function burnFuel(address from, TokenFuel memory fuel) public override { require(_callerIsDeployTimeKnownContract(), "PRPS-2"); _burnFuel(from, fuel); } function _burnFuel(address from, TokenFuel memory fuel) private { require(fuel.amount <= MAX_BOOSTER_FUEL, "PRPS-10"); require(from != address(0) && from != msg.sender, "PRPS-11"); if (fuel.tokenAlias == TOKEN_FUEL_ALIAS_UNLOCKED_PRPS) { // Burn fuel from unlocked PRPS UnpackedData memory unpacked = _unpackPackedData(_packedData[from]); require(unpacked.balance >= fuel.amount, "PRPS-7"); unpacked.balance -= fuel.amount; _packedData[from] = _packUnpackedData(unpacked); return; } if (fuel.tokenAlias == TOKEN_FUEL_ALIAS_LOCKED_PRPS) { // Burn fuel from locked PRPS UnpackedData memory unpacked = _unpackPackedData(_packedData[from]); require(unpacked.hodlBalance >= fuel.amount, "PRPS-7"); unpacked.hodlBalance -= fuel.amount; // We pass a mint timestamp, but that doesn't mean that DUBI is minted. // The returned DUBI that should be minted is ignored. // Reverts if not enough locked PRPS can be burned. _hodl.burnLockedPrps({ from: from, amount: fuel.amount, dubiMintTimestamp: uint32(block.timestamp), burnPendingLockedPrps: false }); _packedData[from] = _packUnpackedData(unpacked); return; } revert("PRPS-12"); } /** *@dev Burn the fuel of a `boostedSend` */ function _burnBoostedSendFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked ) internal override returns (FuelBurn memory) { FuelBurn memory fuelBurn; if (fuel.unlockedPrps > 0) { require(fuel.unlockedPrps <= MAX_BOOSTER_FUEL, "PRPS-10"); require(unpacked.balance >= fuel.unlockedPrps, "PRPS-7"); unpacked.balance -= fuel.unlockedPrps; fuelBurn.amount = fuel.unlockedPrps; fuelBurn.fuelType = FuelType.UNLOCKED_PRPS; return fuelBurn; } if (fuel.lockedPrps > 0) { require(fuel.lockedPrps <= MAX_BOOSTER_FUEL, "PRPS-10"); // We pass a mint timestamp, but that doesn't mean that DUBI is minted. // The returned DUBI that should be minted is ignored. // Reverts if not enough locked PRPS can be burned. _hodl.burnLockedPrps({ from: from, amount: fuel.lockedPrps, dubiMintTimestamp: uint32(block.timestamp), burnPendingLockedPrps: false }); require(unpacked.hodlBalance >= fuel.lockedPrps, "PRPS-7"); unpacked.hodlBalance -= fuel.lockedPrps; fuelBurn.amount = fuel.lockedPrps; fuelBurn.fuelType = FuelType.LOCKED_PRPS; return fuelBurn; } // If the fuel is DUBI, then we have to reach out to the DUBI contract. if (fuel.dubi > 0) { // Reverts if the requested amount cannot be burned _dubi.burnFuel( from, TokenFuel({ tokenAlias: TOKEN_FUEL_ALIAS_DUBI, amount: fuel.dubi }) ); fuelBurn.amount = fuel.dubi; fuelBurn.fuelType = FuelType.DUBI; return fuelBurn; } return fuelBurn; } /** *@dev Burn the fuel of a `boostedBurn` */ function _burnBoostedBurnFuel( address from, BoosterFuel memory fuel, UnpackedData memory unpacked ) internal override returns (FuelBurn memory) { FuelBurn memory fuelBurn; if (fuel.unlockedPrps > 0) { require(fuel.unlockedPrps <= MAX_BOOSTER_FUEL, "PRPS-10"); require(unpacked.balance >= fuel.unlockedPrps, "PRPS-7"); unpacked.balance -= fuel.unlockedPrps; fuelBurn.amount = fuel.unlockedPrps; fuelBurn.fuelType = FuelType.UNLOCKED_PRPS; return fuelBurn; } if (fuel.lockedPrps > 0) { require(fuel.lockedPrps <= MAX_BOOSTER_FUEL, "PRPS-10"); require(unpacked.hodlBalance >= fuel.lockedPrps, "PRPS-7"); // Fuel is taken from hodl balance in _beforeBurn // unpacked.hodlBalance -= fuel.lockedPrps; fuelBurn.amount = fuel.lockedPrps; fuelBurn.fuelType = FuelType.LOCKED_PRPS; return fuelBurn; } if (fuel.intrinsicFuel > 0) { require(fuel.intrinsicFuel <= MAX_BOOSTER_FUEL, "PRPS-10"); fuelBurn.amount = fuel.intrinsicFuel; fuelBurn.fuelType = FuelType.AUTO_MINTED_DUBI; return fuelBurn; } // If the fuel is DUBI, then we have to reach out to the DUBI contract. if (fuel.dubi > 0) { // Reverts if the requested amount cannot be burned _dubi.burnFuel( from, TokenFuel({ tokenAlias: TOKEN_FUEL_ALIAS_DUBI, amount: fuel.dubi }) ); fuelBurn.amount = fuel.dubi; fuelBurn.fuelType = FuelType.DUBI; return fuelBurn; } // No fuel at all return fuelBurn; } //--------------------------------------------------------------- // Pending ops //--------------------------------------------------------------- function _getHasherContracts() internal override returns (address[] memory) { address[] memory hashers = new address[](5); hashers[0] = address(this); hashers[1] = address(_dubi); hashers[2] = _hodlAddress; hashers[3] = _externalAddress1; hashers[4] = _externalAddress2; return hashers; } /** * @dev Create a pending transfer by moving the funds of `spender` to this contract. * Special behavior applies to pending burns to account for locked PRPS. */ function _createPendingTransferInternal( OpHandle memory opHandle, address spender, address from, address to, uint256 amount, bytes memory data ) internal override returns (PendingTransfer memory) { if (opHandle.opType != OP_TYPE_BURN) { return // Nothing special to do for non-burns so just call parent implementation super._createPendingTransferInternal( opHandle, spender, from, to, amount, data ); } // When burning, we first use unlocked PRPS and match the remaining amount with locked PRPS from the Hodl contract. // Sanity check assert(amount < 2**96); uint96 transferAmount = uint96(amount); uint96 lockedPrpsAmount = transferAmount; UnpackedData memory unpacked = _unpackPackedData(_packedData[from]); // First try to move as much unlocked PRPS as possible to the PRPS address uint96 unlockedPrpsToMove = transferAmount; if (unlockedPrpsToMove > unpacked.balance) { unlockedPrpsToMove = unpacked.balance; } // Update the locked PRPS we have to use lockedPrpsAmount -= unlockedPrpsToMove; if (unlockedPrpsToMove > 0) { _move({from: from, to: address(this), amount: unlockedPrpsToMove}); } // If we still need locked PRPS, call into the Hodl contract. // This will also take pending hodls into account, if `from` has // some. if (lockedPrpsAmount > 0) { // Reverts if not the exact amount can be set to pending _hodl.setLockedPrpsToPending(from, lockedPrpsAmount); } // Create pending transfer return PendingTransfer({ spender: spender, transferAmount: transferAmount, to: to, occupiedAmount: lockedPrpsAmount, data: data }); } /** * @dev Hook that is called during revert of a pending op. * Reverts any changes to locked PRPS when 'opType' is burn. */ function _onRevertPendingOp( address user, uint8 opType, uint64 opId, uint96 transferAmount, uint96 occupiedAmount ) internal override { if (opType != OP_TYPE_BURN) { return; } // Extract the pending locked PRPS from the amount. if (occupiedAmount > 0) { _hodl.revertLockedPrpsSetToPending(user, occupiedAmount); } } //--------------------------------------------------------------- // Shared pending ops for Hodl //--------------------------------------------------------------- /** * @dev Creates a new opHandle with the given type for `user`. Hodl and Prps share the same * opCounter to enforce a consistent order in which pending ops are finalized/reverted * across contracts. This function can only be called by Hodl. */ function createNewOpHandleShared( IOptIn.OptInStatus memory optInStatus, address user, uint8 opType ) public onlyHodl returns (OpHandle memory) { return _createNewOpHandle(optInStatus, user, opType); } /** * @dev Delete the op handle with the given `opId` from `user`. Hodl and Prps share the same * opCounter to enforce a consistent order in which pending ops are finalized/reverted * across contracts. This function can only be called by Hodl. */ function deleteOpHandleShared(address user, OpHandle memory opHandle) public onlyHodl returns (bool) { _deleteOpHandle(user, opHandle); return true; } /** * @dev Get the next op id for `user`. Hodl and Prps share the same * opCounter to enforce a consistent order in which pending ops are finalized/reverted * across contracts. This function can only be called by Hodl. */ function assertFinalizeFIFOShared(address user, uint64 opId) public onlyHodl returns (bool) { _assertFinalizeFIFO(user, opId); return true; } /** * @dev Get the next op id for `user`. Hodl and Prps share the same * opCounter to enforce a consistent order in which pending ops are finalized/reverted * across contracts. This function can only be called by Hodl. */ function assertRevertLIFOShared(address user, uint64 opId) public onlyHodl returns (bool) { _assertRevertLIFO(user, opId); return true; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @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 "../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; /** * @dev Interface of the global ERC1820 Registry, as defined in the * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register * implementers for interfaces in this registry, as well as query support. * * Implementers may be shared by multiple accounts, and can also implement more * than a single interface for each account. Contracts can implement interfaces * for themselves, but externally-owned accounts (EOA) must delegate this to a * contract. * * {IERC165} interfaces can also be queried via the registry. * * For an in-depth explanation and source code analysis, see the EIP text. */ interface IERC1820Registry { /** * @dev Sets `newManager` as the manager for `account`. A manager of an * account is able to set interface implementers for it. * * By default, each account is its own manager. Passing a value of `0x0` in * `newManager` will reset the manager to this initial state. * * Emits a {ManagerChanged} event. * * Requirements: * * - the caller must be the current manager for `account`. */ function setManager(address account, address newManager) external; /** * @dev Returns the manager for `account`. * * See {setManager}. */ function getManager(address account) external view returns (address); /** * @dev Sets the `implementer` contract as ``account``'s implementer for * `interfaceHash`. * * `account` being the zero address is an alias for the caller's address. * The zero address can also be used in `implementer` to remove an old one. * * See {interfaceHash} to learn how these are created. * * Emits an {InterfaceImplementerSet} event. * * Requirements: * * - the caller must be the current manager for `account`. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not * end in 28 zeroes). * - `implementer` must implement {IERC1820Implementer} and return true when * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ function setInterfaceImplementer(address account, bytes32 interfaceHash, address implementer) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such * implementer is registered, returns the zero address. * * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 * zeroes), `account` will be queried for support of it. * * `account` being the zero address is an alias for the caller's address. */ function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address); /** * @dev Returns the interface hash for an `interfaceName`, as defined in the * corresponding * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. */ function interfaceHash(string calldata interfaceName) external pure returns (bytes32); /** * @notice Updates the cache with whether the contract implements an ERC165 interface or not. * @param account Address of the contract for which to update the cache. * @param interfaceId ERC165 interface for which to update the cache. */ function updateERC165Cache(address account, bytes4 interfaceId) external; /** * @notice Checks whether a contract implements an ERC165 interface or not. * If the result is not cached a direct lookup on the contract address is performed. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling * {updateERC165Cache} with the contract address. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); /** * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); event ManagerChanged(address indexed account, address indexed newManager); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; // Token agnostic fuel struct that is passed around when the fuel is burned by a different (token) contract. // The contract has to explicitely support the desired token that should be burned. struct TokenFuel { // A token alias that must be understood by the target contract uint8 tokenAlias; uint96 amount; } /** * @dev Extends the interface of the ERC20 standard as defined in the EIP with * `boostedTransferFrom` to perform transfers without having to rely on an allowance. */ interface IBoostableERC20 { // ERC20 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 ); // Extension /** * @dev Moves `amount` tokens from `sender` to `recipient`. * * If the caller is known by the callee, then the implementation should skip approval checks. * Also accepts a data payload, similar to ERC721's `safeTransferFrom` to pass arbitrary data. * */ function boostedTransferFrom( address sender, address recipient, uint256 amount, bytes calldata data ) external returns (bool); /** * @dev Burns `fuel` from `from`. */ function burnFuel(address from, TokenFuel memory fuel) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./Boostable.sol"; import "./BoostableLib.sol"; /** * @dev EIP712 boostable primitives related to ERC20 for the Purpose domain */ abstract contract BoostableERC20 is Boostable { /** * @dev A struct representing the payload of the ERC20 `boostedSend` function. */ struct BoostedSend { uint8 tag; address sender; address recipient; uint256 amount; bytes data; BoosterFuel fuel; BoosterPayload boosterPayload; } /** * @dev A struct representing the payload of the ERC20 `boostedBurn` function. */ struct BoostedBurn { uint8 tag; address account; uint256 amount; bytes data; BoosterFuel fuel; BoosterPayload boosterPayload; } uint8 internal constant BOOST_TAG_SEND = 0; uint8 internal constant BOOST_TAG_BURN = 1; bytes32 internal constant BOOSTED_SEND_TYPEHASH = keccak256( "BoostedSend(uint8 tag,address sender,address recipient,uint256 amount,bytes data,BoosterFuel fuel,BoosterPayload boosterPayload)BoosterFuel(uint96 dubi,uint96 unlockedPrps,uint96 lockedPrps,uint96 intrinsicFuel)BoosterPayload(address booster,uint64 timestamp,uint64 nonce,bool isLegacySignature)" ); bytes32 internal constant BOOSTED_BURN_TYPEHASH = keccak256( "BoostedBurn(uint8 tag,address account,uint256 amount,bytes data,BoosterFuel fuel,BoosterPayload boosterPayload)BoosterFuel(uint96 dubi,uint96 unlockedPrps,uint96 lockedPrps,uint96 intrinsicFuel)BoosterPayload(address booster,uint64 timestamp,uint64 nonce,bool isLegacySignature)" ); constructor(address optIn) public Boostable(optIn) {} /** * @dev Returns the hash of `boostedSend`. */ function hashBoostedSend(BoostedSend memory send, address booster) internal view returns (bytes32) { return BoostableLib.hashWithDomainSeparator( _DOMAIN_SEPARATOR, keccak256( abi.encode( BOOSTED_SEND_TYPEHASH, BOOST_TAG_SEND, send.sender, send.recipient, send.amount, keccak256(send.data), BoostableLib.hashBoosterFuel(send.fuel), BoostableLib.hashBoosterPayload( send.boosterPayload, booster ) ) ) ); } /** * @dev Returns the hash of `boostedBurn`. */ function hashBoostedBurn(BoostedBurn memory burn, address booster) internal view returns (bytes32) { return BoostableLib.hashWithDomainSeparator( _DOMAIN_SEPARATOR, keccak256( abi.encode( BOOSTED_BURN_TYPEHASH, BOOST_TAG_BURN, burn.account, burn.amount, keccak256(burn.data), BoostableLib.hashBoosterFuel(burn.fuel), BoostableLib.hashBoosterPayload( burn.boosterPayload, booster ) ) ) ); } /** * @dev Tries to interpret the given boosterMessage and * return it's hash plus creation timestamp. */ function decodeAndHashBoosterMessage( address targetBooster, bytes memory boosterMessage ) external override view returns (bytes32, uint64) { require(boosterMessage.length > 0, "PB-7"); uint8 tag = _readBoosterTag(boosterMessage); if (tag == BOOST_TAG_SEND) { BoostedSend memory send = abi.decode(boosterMessage, (BoostedSend)); return ( hashBoostedSend(send, targetBooster), send.boosterPayload.timestamp ); } if (tag == BOOST_TAG_BURN) { BoostedBurn memory burn = abi.decode(boosterMessage, (BoostedBurn)); return ( hashBoostedBurn(burn, targetBooster), burn.boosterPayload.timestamp ); } // Unknown tag, so just return an empty result return ("", 0); } } // 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.12; pragma experimental ABIEncoderV2; import "./ProtectedBoostable.sol"; /** * @dev Purpose Boostable primitives using the EIP712 standard */ abstract contract Boostable is ProtectedBoostable { // "Purpose", "Dubi" and "Hodl" are all under the "Purpose" umbrella constructor(address optIn) public ProtectedBoostable( optIn, keccak256( abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256("Purpose"), keccak256("1"), _getChainId(), address(this) ) ) ) {} // Fuel alias constants - used when fuel is burned from external contract calls uint8 internal constant TOKEN_FUEL_ALIAS_UNLOCKED_PRPS = 0; uint8 internal constant TOKEN_FUEL_ALIAS_LOCKED_PRPS = 1; uint8 internal constant TOKEN_FUEL_ALIAS_DUBI = 2; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; struct BoosterFuel { uint96 dubi; uint96 unlockedPrps; uint96 lockedPrps; uint96 intrinsicFuel; } struct BoosterPayload { address booster; uint64 timestamp; uint64 nonce; // Fallback for 'personal_sign' when e.g. using hardware wallets that don't support // EIP712 signing (yet). bool isLegacySignature; } // Library for Boostable hash functions that are completely inlined. library BoostableLib { bytes32 private constant BOOSTER_PAYLOAD_TYPEHASH = keccak256( "BoosterPayload(address booster,uint64 timestamp,uint64 nonce,bool isLegacySignature)" ); bytes32 internal constant BOOSTER_FUEL_TYPEHASH = keccak256( "BoosterFuel(uint96 dubi,uint96 unlockedPrps,uint96 lockedPrps,uint96 intrinsicFuel)" ); /** * @dev Returns the hash of the packed DOMAIN_SEPARATOR and `messageHash` and is used for verifying * a signature. */ function hashWithDomainSeparator( bytes32 domainSeparator, bytes32 messageHash ) internal pure returns (bytes32) { return keccak256( abi.encodePacked("\x19\x01", domainSeparator, messageHash) ); } /** * @dev Returns the hash of `payload` using the provided booster (i.e. `msg.sender`). */ function hashBoosterPayload(BoosterPayload memory payload, address booster) internal pure returns (bytes32) { return keccak256( abi.encode( BOOSTER_PAYLOAD_TYPEHASH, booster, payload.timestamp, payload.nonce, payload.isLegacySignature ) ); } function hashBoosterFuel(BoosterFuel memory fuel) internal pure returns (bytes32) { return keccak256( abi.encode( BOOSTER_FUEL_TYPEHASH, fuel.dubi, fuel.unlockedPrps, fuel.lockedPrps, fuel.intrinsicFuel ) ); } /** * @dev Returns the tag found in the given `boosterMessage`. */ function _readBoosterTag(bytes memory boosterMessage) internal pure returns (uint8) { // The tag is either the 32th byte or the 64th byte depending on whether // the booster message contains dynamic bytes or not. // // If it contains a dynamic byte array, then the first word points to the first // data location. // // Therefore, we read the 32th byte and check if it's >= 32 and if so, // simply read the (32 + first word)th byte to get the tag. // // This imposes a limit on the number of tags we can support (<32), but // given that it is very unlikely for so many tags to exist it is fine. // // Read the 32th byte to get the tag, because it is a uint8 padded to 32 bytes. // i.e. // -----------------------------------------------------------------v // 0x0000000000000000000000000000000000000000000000000000000000000001 // ... // uint8 tag = uint8(boosterMessage[31]); if (tag >= 32) { // Read the (32 + tag) byte. E.g. if tag is 32, then we read the 64th: // -------------------------------------------------------------------- // 0x0000000000000000000000000000000000000000000000000000000000000020 | // 0000000000000000000000000000000000000000000000000000000000000001 < // ... // tag = uint8(boosterMessage[31 + tag]); } return tag; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "./EIP712Boostable.sol"; import "./IOptIn.sol"; import "./ProtectedBoostableLib.sol"; abstract contract ProtectedBoostable is EIP712Boostable { //--------------------------------------------------------------- // State for non-boosted operations while opted-in and the OPT_IN permaboost is active //--------------------------------------------------------------- uint256 private constant MAX_PENDING_OPS = 25; // A mapping of account to an opCounter. mapping(address => OpCounter) internal _opCounters; // A mapping of account to an array containing all it's pending ops. mapping(address => OpHandle[]) internal _pendingOpsByAddress; // A mapping of keccak256(address,opId) to a struct holding metadata like the associated user account and creation timestamp. mapping(bytes32 => OpMetadata) internal _opMetadata; // Event that is emitted whenever a pending op is created // NOTE: returning an OpHandle in the event flattens it into an array for some reason // i.e. emit PendingOp(0x123.., OpHandle(1, 0)) => { from: 0x123, opHandle: ['1', '0']} event PendingOp(address from, uint64 opId, uint8 opType); // Event that is emitted whenever a pending op is finalized event FinalizedOp(address from, uint64 opId, uint8 opType); // Event that is emitted whenever a pending op is reverted event RevertedOp(address from, uint64 opId, uint8 opType); constructor(address optIn, bytes32 domainSeparator) public EIP712Boostable(optIn, domainSeparator) {} //--------------------------------------------------------------- // Pending ops //--------------------------------------------------------------- /** * @dev Returns the metadata of an op. Returns a zero struct if it doesn't exist. */ function getOpMetadata(address user, uint64 opId) public virtual view returns (OpMetadata memory) { return _opMetadata[_getOpKey(user, opId)]; } /** * @dev Returns the metadata of an op. Returns a zero struct if it doesn't exist. */ function getOpCounter(address user) public virtual view returns (OpCounter memory) { return _opCounters[user]; } /** * @dev Returns the metadata of an op. Reverts if it doesn't exist or * the opType mismatches. */ function safeGetOpMetadata(address user, OpHandle memory opHandle) public virtual view returns (OpMetadata memory) { OpMetadata storage metadata = _opMetadata[_getOpKey( user, opHandle.opId )]; // If 'createdAt' is zero, then it's non-existent for us require(metadata.createdAt > 0, "PB-1"); require(metadata.opType == opHandle.opType, "PB-2"); return metadata; } /** * @dev Get the next op id for `user` */ function _getNextOpId(address user) internal returns (uint64) { OpCounter storage counter = _opCounters[user]; // NOTE: we always increase by 1, so it cannot overflow as long as this // is the only place increasing the counter. uint64 nextOpId = counter.value + 1; // This also updates the nextFinalize/Revert values if (counter.nextFinalize == 0) { // Only gets updated if currently pointing to "nothing", because FIFO counter.nextFinalize = nextOpId; } // nextRevert is always updated to the new opId, because LIFO counter.nextRevert = nextOpId; counter.value = nextOpId; // NOTE: It is safe to downcast to uint64 since it's practically impossible to overflow. return nextOpId; } /** * @dev Creates a new opHandle with the given type for `user`. */ function _createNewOpHandle( IOptIn.OptInStatus memory optInStatus, address user, uint8 opType ) internal virtual returns (OpHandle memory) { uint64 nextOpId = _getNextOpId(user); OpHandle memory opHandle = OpHandle({opId: nextOpId, opType: opType}); // NOTE: we have a hard limit of 25 pending OPs and revert if that // limit is exceeded. require(_pendingOpsByAddress[user].length < MAX_PENDING_OPS, "PB-3"); address booster = optInStatus.optedInTo; _pendingOpsByAddress[user].push(opHandle); _opMetadata[_getOpKey(user, nextOpId)] = OpMetadata({ createdAt: uint64(block.timestamp), booster: booster, opType: opType }); return opHandle; } /** * @dev Delete the given `opHandle` from `user`. */ function _deleteOpHandle(address user, OpHandle memory opHandle) internal virtual { OpHandle[] storage _opHandles = _pendingOpsByAddress[user]; OpCounter storage opCounter = _opCounters[user]; ProtectedBoostableLib.deleteOpHandle( user, opHandle, _opHandles, opCounter, _opMetadata ); } /** * @dev Assert that the caller is allowed to finalize a pending op. * * Returns the user and createdAt timestamp of the op on success in order to * save some gas by minimizing redundant look-ups. */ function _assertCanFinalize(address user, OpHandle memory opHandle) internal returns (uint64) { OpMetadata memory metadata = safeGetOpMetadata(user, opHandle); uint64 createdAt = metadata.createdAt; // First check if the user is still opted-in. If not, then anyone // can finalize since it is no longer associated with the original booster. IOptIn.OptInStatus memory optInStatus = getOptInStatus(user); if (!optInStatus.isOptedIn) { return createdAt; } // Revert if not FIFO order _assertFinalizeFIFO(user, opHandle.opId); return ProtectedBoostableLib.assertCanFinalize(metadata, optInStatus); } /** * @dev Asserts that the caller (msg.sender) is allowed to revert a pending operation. * The caller must be opted-in by user and provide a valid signature from the user * that hasn't expired yet. */ function _assertCanRevert( address user, OpHandle memory opHandle, uint64 opTimestamp, bytes memory boosterMessage, Signature memory signature ) internal { // Revert if not LIFO order _assertRevertLIFO(user, opHandle.opId); IOptIn.OptInStatus memory optInStatus = getOptInStatus(user); require( optInStatus.isOptedIn && msg.sender == optInStatus.optedInTo, "PB-6" ); // In order to verify the boosterMessage, we need the hash and timestamp of when it // was signed. To interpret the boosterMessage, consult all available hasher contracts and // take the first non-zero result. address[] memory hasherContracts = _getHasherContracts(); // Call external library function, which performs the actual assertion. The reason // why it is not inlined, is that the need to reduce bytecode size. ProtectedBoostableLib.verifySignatureForRevert( user, opTimestamp, optInStatus, boosterMessage, hasherContracts, signature ); } function _getHasherContracts() internal virtual returns (address[] memory); /** * @dev Asserts that the given opId is the next to be finalized for `user`. */ function _assertFinalizeFIFO(address user, uint64 opId) internal virtual { OpCounter storage counter = _opCounters[user]; require(counter.nextFinalize == opId, "PB-9"); } /** * @dev Asserts that the given opId is the next to be reverted for `user`. */ function _assertRevertLIFO(address user, uint64 opId) internal virtual { OpCounter storage counter = _opCounters[user]; require(counter.nextRevert == opId, "PB-10"); } /** * @dev Prepare an op revert. * - Asserts that the caller is allowed to revert the given op * - Deletes the op handle to minimize risks of reentrancy */ function _prepareOpRevert( address user, OpHandle memory opHandle, bytes memory boosterMessage, Signature memory signature ) internal { OpMetadata memory metadata = safeGetOpMetadata(user, opHandle); _assertCanRevert( user, opHandle, metadata.createdAt, boosterMessage, signature ); // Delete opHandle, which prevents reentrancy since `safeGetOpMetadata` // will fail afterwards. _deleteOpHandle(user, opHandle); } /** * @dev Returns the hash of (user, opId) which is used as a look-up * key in the `_opMetadata` mapping. */ function _getOpKey(address user, uint64 opId) internal pure returns (bytes32) { return keccak256(abi.encodePacked(user, opId)); } /** * @dev Deriving contracts can override this function to accept a boosterMessage for a given booster and * interpret it into a hash and timestamp. */ function decodeAndHashBoosterMessage( address targetBooster, bytes memory boosterMessage ) external virtual view returns (bytes32, uint64) {} /** * @dev Returns the tag found in the given `boosterMesasge`. */ function _readBoosterTag(bytes memory boosterMessage) internal pure returns (uint8) { // The tag is either the 32th byte or the 64th byte depending on whether // the booster message contains dynamic bytes or not. // // If it contains a dynamic byte array, then the first word points to the first // data location. // // Therefore, we read the 32th byte and check if it's >= 32 and if so, // simply read the (32 + first word)th byte to get the tag. // // This imposes a limit on the number of tags we can support (<32), but // given that it is very unlikely for so many tags to exist it is fine. // // Read the 32th byte to get the tag, because it is a uint8 padded to 32 bytes. // i.e. // -----------------------------------------------------------------v // 0x0000000000000000000000000000000000000000000000000000000000000001 // ... // uint8 tag = uint8(boosterMessage[31]); if (tag >= 32) { // Read the (32 + tag) byte. E.g. if tag is 32, then we read the 64th: // -------------------------------------------------------------------- // 0x0000000000000000000000000000000000000000000000000000000000000020 | // 0000000000000000000000000000000000000000000000000000000000000001 < // ... // tag = uint8(boosterMessage[31 + tag]); } return tag; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/cryptography/ECDSA.sol"; import "./IOptIn.sol"; import "./BoostableLib.sol"; import "./IBoostableERC20.sol"; /** * @dev Boostable base contract * * All deriving contracts are expected to implement EIP712 for the message signing. * */ abstract contract EIP712Boostable { using ECDSA for bytes32; // solhint-disable-next-line var-name-mixedcase IOptIn internal immutable _OPT_IN; // solhint-disable-next-line var-name-mixedcase bytes32 internal immutable _DOMAIN_SEPARATOR; bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); bytes32 private constant BOOSTER_PAYLOAD_TYPEHASH = keccak256( "BoosterPayload(address booster,uint64 timestamp,uint64 nonce,bool isLegacySignature)" ); bytes32 internal constant BOOSTER_FUEL_TYPEHASH = keccak256( "BoosterFuel(uint96 dubi,uint96 unlockedPrps,uint96 lockedPrps,uint96 intrinsicFuel)" ); // The boost fuel is capped to 10 of the respective token that will be used for payment. uint96 internal constant MAX_BOOSTER_FUEL = 10 ether; // A magic booster permission prefix bytes6 private constant MAGIC_BOOSTER_PERMISSION_PREFIX = "BOOST-"; constructor(address optIn, bytes32 domainSeparator) public { _OPT_IN = IOptIn(optIn); _DOMAIN_SEPARATOR = domainSeparator; } // A mapping of mappings to keep track of used nonces by address to // protect against replays. Each 'Boostable' contract maintains it's own // state for nonces. mapping(address => uint64) private _nonces; //--------------------------------------------------------------- function getNonce(address account) external virtual view returns (uint64) { return _nonces[account]; } function getOptInStatus(address account) internal view returns (IOptIn.OptInStatus memory) { return _OPT_IN.getOptInStatus(account); } /** * @dev Called by every 'boosted'-function to ensure that `msg.sender` (i.e. a booster) is * allowed to perform the call for `from` (the origin) by verifying that `messageHash` * has been signed by `from`. Additionally, `from` provides a nonce to prevent * replays. Boosts cannot be verified out of order. * * @param from the address that the boost is made for * @param messageHash the reconstructed message hash based on the function input * @param payload the booster payload * @param signature the signature of `from` */ function verifyBoost( address from, bytes32 messageHash, BoosterPayload memory payload, Signature memory signature ) internal { uint64 currentNonce = _nonces[from]; require(currentNonce == payload.nonce - 1, "AB-1"); _nonces[from] = currentNonce + 1; _verifyBoostWithoutNonce(from, messageHash, payload, signature); } /** * @dev Verify a boost without verifying the nonce. */ function _verifyBoostWithoutNonce( address from, bytes32 messageHash, BoosterPayload memory payload, Signature memory signature ) internal view { // The sender must be the booster specified in the payload require(msg.sender == payload.booster, "AB-2"); (bool isOptedInToSender, uint256 optOutPeriod) = _OPT_IN.isOptedInBy( msg.sender, from ); // `from` must be opted-in to booster require(isOptedInToSender, "AB-3"); // The given timestamp must not be greater than `block.timestamp + 1 hour` // and at most `optOutPeriod(booster)` seconds old. uint64 _now = uint64(block.timestamp); uint64 _optOutPeriod = uint64(optOutPeriod); bool notTooFarInFuture = payload.timestamp <= _now + 1 hours; bool belowMaxAge = true; // Calculate the absolute difference. Because of the small tolerance, `payload.timestamp` // may be greater than `_now`: if (payload.timestamp <= _now) { belowMaxAge = _now - payload.timestamp <= _optOutPeriod; } // Signature must not be expired require(notTooFarInFuture && belowMaxAge, "AB-4"); // NOTE: Currently, hardware wallets (e.g. Ledger, Trezor) do not support EIP712 signing (specifically `signTypedData_v4`). // However, a user can still sign the EIP712 hash with the caveat that it's signed using `personal_sign` which prepends // the prefix '"\x19Ethereum Signed Message:\n" + len(message)'. // // To still support that, we add the prefix to the hash if `isLegacySignature` is true. if (payload.isLegacySignature) { messageHash = messageHash.toEthSignedMessageHash(); } // Valid, if the recovered address from `messageHash` with the given `signature` matches `from`. address signer = ecrecover( messageHash, signature.v, signature.r, signature.s ); if (!payload.isLegacySignature && signer != from) { // As a last resort we try anyway, in case the caller simply forgot the `isLegacySignature` flag. signer = ecrecover( messageHash.toEthSignedMessageHash(), signature.v, signature.r, signature.s ); } require(from == signer, "AB-5"); } /** * @dev Returns the hash of `payload` using the provided booster (i.e. `msg.sender`). */ function hashBoosterPayload(BoosterPayload memory payload, address booster) internal pure returns (bytes32) { return keccak256( abi.encode( BOOSTER_PAYLOAD_TYPEHASH, booster, payload.timestamp, payload.nonce ) ); } function _getChainId() internal pure returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; struct Signature { bytes32 r; bytes32 s; uint8 v; } interface IOptIn { struct OptInStatus { bool isOptedIn; bool permaBoostActive; address optedInTo; uint32 optOutPeriod; } function getOptInStatusPair(address accountA, address accountB) external view returns (OptInStatus memory, OptInStatus memory); function getOptInStatus(address account) external view returns (OptInStatus memory); function isOptedInBy(address _sender, address _account) external view returns (bool, uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/cryptography/ECDSA.sol"; import "./IOptIn.sol"; struct OpHandle { uint8 opType; uint64 opId; } struct OpMetadata { uint8 opType; // the operation type uint64 createdAt; // the creation timestamp of an op address booster; // the booster at the time of when the op has been created } struct OpCounter { // The current value of the counter uint64 value; // Contains the opId that is to be finalized next - i.e. FIFO order uint64 nextFinalize; // Contains the opId that is to be reverted next - i.e. LIFO order uint64 nextRevert; } // Library containing public functions for pending ops - those will never be inlined // to reduce the bytecode size of individual contracts. library ProtectedBoostableLib { using ECDSA for bytes32; function deleteOpHandle( address user, OpHandle memory opHandle, OpHandle[] storage opHandles, OpCounter storage opCounter, mapping(bytes32 => OpMetadata) storage opMetadata ) public { uint256 length = opHandles.length; assert(length > 0); uint64 minOpId; // becomes next LIFO uint64 maxOpId; // becomes next FIFO // Pending ops are capped to MAX_PENDING_OPS. We always perform // MIN(length, MAX_PENDING_OPS) look-ups to do a "swap-and-pop" and // for updating the opCounter LIFO/FIFO pointers. for (uint256 i = 0; i < length; i++) { uint64 currOpId = opHandles[i].opId; if (currOpId == opHandle.opId) { // Overwrite item at i with last opHandles[i] = opHandles[length - 1]; // Continue, to ignore this opId when updating // minOpId and maxOpId. continue; } // Update minOpId if (minOpId == 0 || currOpId < minOpId) { minOpId = currOpId; } // Update maxOpId if (currOpId > maxOpId) { maxOpId = currOpId; } } // Might be 0 when everything got finalized/reverted opCounter.nextFinalize = minOpId; // Might be 0 when everything got finalized/reverted opCounter.nextRevert = maxOpId; // Remove the last item opHandles.pop(); // Remove metadata delete opMetadata[_getOpKey(user, opHandle.opId)]; } function assertCanFinalize( OpMetadata memory metadata, IOptIn.OptInStatus memory optInStatus ) public view returns (uint64) { // Now there are three valid scenarios remaining: // // - msg.sender is the original booster // - op is expired // - getBoosterAddress returns a different booster than the original booster // // In the second and third case, anyone can call finalize. address originalBooster = metadata.booster; if (originalBooster == msg.sender) { return metadata.createdAt; // First case } address currentBooster = optInStatus.optedInTo; uint256 optOutPeriod = optInStatus.optOutPeriod; bool isExpired = block.timestamp >= metadata.createdAt + optOutPeriod; if (isExpired) { return metadata.createdAt; // Second case } if (currentBooster != originalBooster) { return metadata.createdAt; // Third case } revert("PB-4"); } function verifySignatureForRevert( address user, uint64 opTimestamp, IOptIn.OptInStatus memory optInStatus, bytes memory boosterMessage, address[] memory hasherContracts, Signature memory signature ) public { require(hasherContracts.length > 0, "PB-12"); // Result of hasher contract call uint64 signedAt; bytes32 boosterHash; bool signatureVerified; for (uint256 i = 0; i < hasherContracts.length; i++) { // Call into the hasher contract and take the first non-zero result. // The contract must implement the following function: // // decodeAndHashBoosterMessage( // address targetBooster, // bytes memory boosterMessage // ) // // If it doesn't, then the call will fail (success=false) and we try the next one. // If it succeeds (success = true), then we try to decode the result. // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory result) = address(hasherContracts[i]) .call( // keccak256("decodeAndHashBoosterMessage(address,bytes)") abi.encodeWithSelector( 0xaf6eec54, msg.sender, /* msg.sender becomes the target booster */ boosterMessage ) ); if (!success) { continue; } // The result is exactly 2 words long = 512 bits = 64 bytes // 32 bytes for the expected message hash // 8 bytes (padded to 32 bytes) for the expected timestamp if (result.length != 64) { continue; } // NOTE: A contract with malintent could return any hash that we would // try to recover against. But there is no harm done in doing so since // the user must have signed it. // // However, it might return an unrelated timestamp, that the user hasn't // signed - so it could prolong the expiry of a signature which is a valid // concern whose risk we minimize by using also the op timestamp which guarantees // that a signature eventually expires. // Decode and recover signer (boosterHash, signedAt) = abi.decode(result, (bytes32, uint64)); address signer = ecrecover( boosterHash, signature.v, signature.r, signature.s ); if (user != signer) { // NOTE: Currently, hardware wallets (e.g. Ledger, Trezor) do not support EIP712 signing (specifically `signTypedData_v4`). // However, a user can still sign the EIP712 hash with the caveat that it's signed using `personal_sign` which prepends // the prefix '"\x19Ethereum Signed Message:\n" + len(message)'. // // To still support that, we also add the prefix and try to use the recovered address instead: signer = ecrecover( boosterHash.toEthSignedMessageHash(), signature.v, signature.r, signature.s ); } // If we recovered `user` from the signature, then we have a valid signature. if (user == signer) { signatureVerified = true; break; } // Keep trying } // Revert if signature couldn't be verified with any of the returned hashes require(signatureVerified, "PB-8"); // Lastly, the current time must not be older than: // MIN(opTimestamp, signedAt) + optOutPeriod * 3 uint64 _now = uint64(block.timestamp); // The maximum age is equal to whichever is lowest: // opTimestamp + optOutPeriod * 3 // signedAt + optOutPeriod * 3 uint64 maximumAge; if (opTimestamp > signedAt) { maximumAge = signedAt + uint64(optInStatus.optOutPeriod * 3); } else { maximumAge = opTimestamp + uint64(optInStatus.optOutPeriod * 3); } require(_now <= maximumAge, "PB-11"); } function _getOpKey(address user, uint64 opId) internal pure returns (bytes32) { return keccak256(abi.encodePacked(user, opId)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { revert("ECDSA: invalid signature 's' value"); } if (v != 27 && v != 28) { revert("ECDSA: invalid signature 'v' value"); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IHodl { /** * @dev Lock the given amount of PRPS for the specified period (or infinitely) * for DUBI. */ function hodl( uint24 id, uint96 amountPrps, uint16 duration, address dubiBeneficiary, address prpsBeneficiary ) external; /** * @dev Release a hodl of `prpsBeneficiary` with the given `creator` and `id`. */ function release( uint24 id, address prpsBeneficiary, address creator ) external; /** * @dev Withdraw can be used to withdraw DUBI from infinitely locked PRPS. * The amount of DUBI withdrawn depends on the time passed since the last withdrawal. */ function withdraw( uint24 id, address prpsBeneficiary, address creator ) external; /** * @dev Burn `amount` of `from`'s locked and/or pending PRPS. * * This function is supposed to be only called by the PRPS contract. * * Returns the amount of DUBI that needs to be minted. */ function burnLockedPrps( address from, uint96 amount, uint32 dubiMintTimestamp, bool burnPendingLockedPrps ) external returns (uint96); /** * @dev Set `amount` of `from`'s locked PRPS to pending. * * This function is supposed to be only called by the PRPS contract. * * Returns the amount of locked PRPS that could be set to pending. */ function setLockedPrpsToPending(address from, uint96 amount) external; /** * @dev Revert `amount` of `from`'s pending locked PRPS to not pending. * * This function is supposed to be only called by the PRPS contract and returns */ function revertLockedPrpsSetToPending(address account, uint96 amount) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; // NOTE: we ignore leap-seconds etc. library MintMath { // The maximum number of seconds per month (365 * 24 * 60 * 60 / 12) uint32 public constant SECONDS_PER_MONTH = 2628000; // The maximum number of days PRPS can be finitely locked for uint16 public constant MAX_FINITE_LOCK_DURATION_DAYS = 365; // The maximum number of seconds PRPS can be finitely locked for uint32 public constant MAX_FINITE_LOCK_DURATION_SECONDS = uint32( MAX_FINITE_LOCK_DURATION_DAYS ) * 24 * 60 * 60; /** * @dev Calculates the DUBI to mint based on the given amount of PRPS and duration in days. * NOTE: We trust the caller to ensure that the duration between 1 and 365. */ function calculateDubiToMintByDays( uint256 amountPrps, uint16 durationInDays ) internal pure returns (uint96) { uint32 durationInSeconds = uint32(durationInDays) * 24 * 60 * 60; return calculateDubiToMintBySeconds(amountPrps, durationInSeconds); } /** * @dev Calculates the DUBI to mint based on the given amount of PRPS and duration in seconds. */ function calculateDubiToMintBySeconds( uint256 amountPrps, uint32 durationInSeconds ) internal pure returns (uint96) { // NOTE: We do not use safe math for efficiency reasons uint256 _percentage = percentage( durationInSeconds, MAX_FINITE_LOCK_DURATION_SECONDS, 18 // precision in WEI, 10^18 ) * 4; // A full lock grants 4%, so multiply by 4. // Multiply PRPS by the percentage and then divide by the precision (=10^8) // from the previous step uint256 _dubiToMint = (amountPrps * _percentage) / (1 ether * 100); // multiply by 100, because we deal with percentages // Assert that the calculated DUBI never overflows uint96 assert(_dubiToMint < 2**96); return uint96(_dubiToMint); } function calculateDubiToMintMax(uint96 amount) internal pure returns (uint96) { return calculateDubiToMintBySeconds( amount, MAX_FINITE_LOCK_DURATION_SECONDS ); } function calculateMintDuration(uint32 _now, uint32 lastWithdrawal) internal pure returns (uint32) { require(lastWithdrawal > 0 && lastWithdrawal <= _now, "MINT-1"); // NOTE: we don't use any safe math here for efficiency reasons. The assert above // is already a pretty good guarantee that nothing goes wrong. Also, all numbers involved // are very well smaller than uint256 in the first place. uint256 _elapsedTotal = _now - lastWithdrawal; uint256 _proRatedYears = _elapsedTotal / SECONDS_PER_MONTH / 12; uint256 _elapsedInYear = _elapsedTotal % MAX_FINITE_LOCK_DURATION_SECONDS; // // Examples (using months instead of seconds): // calculation formula: (monthsSinceWithdrawal % 12) + (_proRatedYears * 12) // 1) Burn after 11 months since last withdrawal (number of years = 11 / 12 + 1 = 1) // => (11 % 12) + (years * 12) => 23 months worth of DUBI // => 23 months // 1) Burn after 4 months since last withdrawal (number of years = 4 / 12 + 1 = 1) // => (4 % 12) + (years * 12) => 16 months worth of DUBI // => 16 months // 2) Burn 0 months after withdrawal after 4 months (number of years = 0 / 12 + 1 = 1): // => (0 % 12) + (years * 12) => 12 months worth of DUBI (+ 4 months worth of withdrawn DUBI) // => 16 months // 3) Burn after 36 months since last withdrawal (number of years = 36 / 12 + 1 = 4) // => (36 % 12) + (years * 12) => 48 months worth of DUBI // => 48 months // 4) Burn 1 month after withdrawal after 35 months (number of years = 1 / 12 + 1 = 1): // => (1 % 12) + (years * 12) => 12 month worth of DUBI (+ 35 months worth of withdrawn DUBI) // => 47 months uint32 _mintDuration = uint32( _elapsedInYear + _proRatedYears * MAX_FINITE_LOCK_DURATION_SECONDS ); return _mintDuration; } function percentage( uint256 numerator, uint256 denominator, uint256 precision ) internal pure returns (uint256) { return ((numerator * (uint256(10)**(precision + 1))) / denominator + 5) / uint256(10); } }
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c8063688d872c1161010f578063a9059cbb116100a2578063dc3b52d711610071578063dc3b52d714610455578063dd62ed3e14610468578063f2fde38b1461047b578063fe9d93031461048e576101f0565b8063a9059cbb146103fb578063af6eec541461040e578063b44be68c1461042f578063b55ff88414610442576101f0565b80638da5cb5b116100de5780638da5cb5b146103ab57806395d89b41146103c05780639cc0b8b3146103c8578063a457c2d7146103e8576101f0565b8063688d872c1461036a57806370a082311461037d578063715018a6146103905780637675dda414610398576101f0565b80632d0335ab1161018757806340c10f191161015657806340c10f191461031e5780634598980b14610331578063470e5a92146103445780634cc9512314610357576101f0565b80632d0335ab146102b65780632ec4ac0a146102d6578063313ce567146102f6578063395093511461030b576101f0565b806318160ddd116101c357806318160ddd1461025b57806323b872dd14610270578063240fa6de14610283578063252b2d20146102a3576101f0565b806306fdde03146101f5578063095ea7b31461021357806309ee40a01461023357806310b4a23d14610246575b600080fd5b6101fd6104a1565b60405161020a9190614182565b60405180910390f35b610226610221366004613969565b610538565b60405161020a919061405c565b610226610241366004613774565b61055c565b6102596102543660046138ff565b6105fd565b005b61026361062f565b60405161020a91906146d7565b61022661027e366004613734565b610635565b61029661029136600461385a565b61073b565b60405161020a9190614676565b6102966102b1366004613994565b6107fe565b6102c96102c43660046136e0565b610868565b60405161020a91906146f9565b6102e96102e43660046136e0565b61089f565b60405161020a919061469f565b6102fe6108c9565b60405161020a919061470d565b610226610319366004613969565b6108ce565b61025961032c366004613969565b610918565b61025961033f366004613969565b610957565b61025961035236600461385a565b61099f565b610259610365366004613a67565b610a58565b610259610378366004613bd4565b610acf565b61026361038b3660046136e0565b610b6a565b610259610b8e565b6102596103a63660046139c1565b610c0d565b6103b3610c7f565b60405161020a9190613edf565b6101fd610c8e565b6103db6103d63660046136e0565b610cef565b60405161020a9190614647565b6102266103f6366004613969565b610d4e565b610226610409366004613969565b610dae565b61042161041c36600461380d565b610e27565b60405161020a92919061409e565b61025961043d36600461388f565b610ef4565b610259610450366004613969565b610f19565b610259610463366004613ce7565b610f61565b6102636104763660046136fc565b611030565b6102596104893660046136e0565b61105b565b61025961049c366004613d8a565b611112565b60068054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561052d5780601f106105025761010080835404028352916020019161052d565b820191906000526020600020905b81548152906001019060200180831161051057829003601f168201915b505050505090505b90565b600033610545818561115e565b61055081858561119a565b60019150505b92915050565b6000610568868661115e565b610570613091565b61057987611202565b90506105be8787878488888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506112a692505050565b6105e35760405162461bcd60e51b81526004016105da9061438e565b60405180910390fd5b6105ee87878761132c565b60019150505b95945050505050565b6106056113a4565b6106215760405162461bcd60e51b81526004016105da906141f6565b61062b82826113ec565b5050565b60055490565b6000610641848461115e565b3361064a613091565b61065386611202565b80519091508015610665575080602001515b156106c557816001600160a01b0316866001600160a01b03161461069b5760405162461bcd60e51b81526004016105da90614313565b6106ba600083888888604051806020016040528060008152508761152d565b600192505050610734565b6040805180820182526007815266115490cc8c0b4d60ca1b6020808301919091526001600160a01b03808a16600090815260098352848120918716815291529190912054610722918891859161071d91908990611644565b61119a565b61072d86868661132c565b6001925050505b9392505050565b6107436130b8565b600060036000610757868660200151611670565b81526020810191909152604001600020805490915061010090046001600160401b03166107965760405162461bcd60e51b81526004016105da906141d8565b8251815460ff9081169116146107be5760405162461bcd60e51b81526004016105da90614216565b60408051606081018252915460ff8116835261010081046001600160401b03166020840152600160481b90046001600160a01b0316908201529392505050565b6108066130b8565b600360006108148585611670565b815260208082019290925260409081016000208151606081018352905460ff8116825261010081046001600160401b031693820193909352600160481b9092046001600160a01b0316908201529392505050565b60006108726130b8565b6001600160a01b038316600090815260086020526040902054610894906116a3565b604001519392505050565b6108a76130b8565b6001600160a01b038216600090815260086020526040902054610556906116a3565b601290565b60006108da338461115e565b3360008181526009602090815260408083206001600160a01b038816845290915290205461090f9190859061071d90866116da565b50600192915050565b6109206116ff565b6004546001600160a01b0390811691161461094d5760405162461bcd60e51b81526004016105da906144d4565b61062b8282611703565b336001600160a01b037f000000000000000000000000ac0122e9258a85ba5479db764dc8ef91cab08db0161461094d5760405162461bcd60e51b81526004016105da906143f0565b805160006109ad8484611815565b905060006109bf8585602001516118f6565b90506109cb8585611941565b60ff83166109e3576109de8186846119dd565b610a12565b60ff8316600114156109fa576109de818684611b55565b60405162461bcd60e51b81526004016105da906143ce565b7ffd1941e7a2d0c6f1cc53e8a73873275917cb8a1cf357e47f86f6e681e5d0f0f185856020015185604051610a499392919061402f565b60405180910390a15050505050565b60008251118015610a6a575080518251145b610a865760405162461bcd60e51b81526004016105da906141b7565b60005b8251811015610aca57610ac2838281518110610aa157fe5b6020026020010151838381518110610ab557fe5b6020026020010151610f61565b600101610a89565b505050565b6020820151610adc6130b8565b6001600160a01b038216600090815260086020526040902054610afe906116a3565b9050610b128460a001518260400151611cef565b610b2f8460200151610b248633611d27565b8660a0015186611dd2565b610b376130d8565b610b4683866080015184612066565b9050610b63856020015183876040015188606001516001866122e6565b5050505050565b6001600160a01b03166000908152600860205260409020546001600160601b031690565b610b966116ff565b6004546001600160a01b03908116911614610bc35760405162461bcd60e51b81526004016105da906144d4565b6004546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600480546001600160a01b0319169055565b60008251118015610c1f575080518251145b610c3b5760405162461bcd60e51b81526004016105da906141b7565b60005b8251811015610aca57610c77838281518110610c5657fe5b6020026020010151838381518110610c6a57fe5b6020026020010151610acf565b600101610c3e565b6004546001600160a01b031690565b60078054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561052d5780601f106105025761010080835404028352916020019161052d565b610cf76130b8565b506001600160a01b0316600090815260016020908152604091829020825160608101845290546001600160401b038082168352600160401b8204811693830193909352600160801b90049091169181019190915290565b6000610d5a338461115e565b604080518082018252600881526708aa48664605a62760c31b602080830191909152336000818152600983528481206001600160a01b03891682529092529290205461090f9291869161071d918790611644565b6000610dba338461115e565b610dc26113a4565b610e1c5733610dcf613091565b610dd882611202565b80519091508015610dea575080602001515b15610e1957610e0e600033338888604051806020016040528060008152508761152d565b600192505050610556565b50505b61090f33848461132c565b6000806000835111610e4b5760405162461bcd60e51b81526004016105da90614352565b6000610e5684612430565b905060ff8116610e9c57610e686130ef565b84806020019051810190610e7c9190613c17565b9050610e888187612474565b8160c0015160200151935093505050610eed565b60ff811660011415610ee457610eb061314c565b84806020019051810190610ec49190613b15565b9050610ed08187611d27565b8160a0015160200151935093505050610eed565b60008092509250505b9250929050565b610f008484848461250a565b610f138484600001518560200151612539565b50505050565b336001600160a01b037f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f12161461094d5760405162461bcd60e51b81526004016105da906145c8565b60208201516040830151610f736130b8565b6001600160a01b038316600090815260086020526040902054610f95906116a3565b9050610f9f6130b8565b6001600160a01b038316600090815260086020526040902054610fc1906116a3565b9050610fd58660c001518360400151611cef565b610ff28660200151610fe78833612474565b8860c0015188611dd2565b610ffa6130d8565b611009858860a00151856125c3565b90506110278760200151848960400151858b6060015160018761274c565b50505050505050565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b6110636116ff565b6004546001600160a01b039081169116146110905760405162461bcd60e51b81526004016105da906144d4565b6001600160a01b0381166110b65760405162461bcd60e51b81526004016105da90614254565b6004546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600480546001600160a01b0319166001600160a01b0392909216919091179055565b61111a613091565b61112333611202565b80519091508015611135575080602001515b156111515761114b60013333600087878761152d565b5061062b565b610aca338484600061287b565b6001600160a01b0382161580159061117e57506001600160a01b03811615155b61062b5760405162461bcd60e51b81526004016105da90614494565b6001600160a01b0380841660008181526009602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906111f59085906146d7565b60405180910390a3505050565b61120a613091565b604051630f425aed60e11b81526001600160a01b037f000000000000000000000000a916bc21d2429645585abede4ae00742a16dd1c61690631e84b5da90611256908590600401613edf565b60806040518083038186803b15801561126e57600080fd5b505afa158015611282573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105569190613d1a565b60006112b06113a4565b6112bc575060006105f4565b336001600160a01b037f000000000000000000000000e7cd2797ac6f08b5721c7e7fcc991251df5e388416146112f4575060016105f4565b60018281015190818116141561130e5760019150506105f4565b8360200151801561131d575083515b156105ee5760009150506105f4565b6113346130b8565b6001600160a01b038416600090815260086020526040902054611356906116a3565b90506113606130b8565b6001600160a01b038416600090815260086020526040902054611382906116a3565b905061138c6130d8565b61139c868487858860008761274c565b505050505050565b6000336001600160a01b037f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f121614156113df57506001610535565b6113e76128e3565b905090565b678ac7230489e800006001600160601b031681602001516001600160601b0316111561142a5760405162461bcd60e51b81526004016105da906145e8565b6001600160a01b0382161580159061144b57506001600160a01b0382163314155b6114675760405162461bcd60e51b81526004016105da906145a8565b805160ff16600214156115155761147c6130b8565b6001600160a01b03831660009081526008602052604090205461149e906116a3565b905081602001516001600160601b031681600001516001600160601b031610156114da5760405162461bcd60e51b81526004016105da90614234565b60208201518151036001600160601b031681526114f6816129cf565b6001600160a01b0384166000908152600860205260409020555061062b565b60405162461bcd60e51b81526004016105da906142f3565b6115356130d8565b61154082878a612a16565b905061154a613187565b611558828989898989612bb4565b905080600a600061156d8a8660200151611670565b8152602080820192909252604090810160002083518154858501516001600160601b03908116600160a01b9081026001600160a01b039485166001600160a01b03199485161785161785559487015160018501805460608a01519093169096029084169190921617909116179091556080830151805191926115f7926002850192909101906131b7565b505050602082015182516040517fa824f616acaccd5102c745c13e260dc1ca704e95425ebc56e73a6e495d5a3d8992611631928b9261402f565b60405180910390a1505050505050505050565b600081848411156116685760405162461bcd60e51b81526004016105da9190614182565b505050900390565b60008282604051602001611685929190613e64565b60405160208183030381529060405280519060200120905092915050565b6116ab6130b8565b6116b36130b8565b6001600160601b038381168252606084901c16602082015260c09290921c60408301525090565b6000828201838110156107345760405162461bcd60e51b81526004016105da906142bc565b3390565b6001600160a01b0382166117295760405162461bcd60e51b81526004016105da90614608565b80606081901c6001600160601b0381161561174c576001600160601b0381166005555b6117546130b8565b6001600160a01b038516600090815260086020526040902054611776906116a3565b80516020820151919250808501916001600160601b0391821690830190911610156117b35760405162461bcd60e51b81526004016105da90614509565b6001600160601b03811682526117c8826129cf565b6001600160a01b0387166000818152600860205260408082209390935591519091906000805160206148cd8339815191529061180590889061471b565b60405180910390a3505050505050565b600061181f6130b8565b611829848461073b565b6020810151909150611839613091565b61184286611202565b8051909150611855575091506105569050565b611863868660200151612c18565b60405163c2288c7160e01b81527385ae45a05971170b70744292e2f051c0c49cf9099063c2288c719061189c9086908590600401614684565b60206040518083038186803b1580156118b457600080fd5b505af41580156118c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ec9190613db8565b9695505050505050565b600080600a60006119078686611670565b8152602081019190915260400160002080549091506001600160a01b03166107345760405162461bcd60e51b81526004016105da90614472565b6001600160a01b0382166000908152600260209081526040808320600190925291829020915163c112c77160e01b81529091907385ae45a05971170b70744292e2f051c0c49cf9099063c112c771906119a7908790879087908790600390600401613f0d565b60006040518083038186803b1580156119bf57600080fd5b505af41580156119d3573d6000803e3d6000fd5b5050505050505050565b600183015483546001600160a01b0390911690600160a01b90046001600160601b031630611a096130b8565b6001600160a01b038216600090815260086020526040902054611a2b906116a3565b9050611a356130b8565b6001600160a01b038516600090815260086020526040902054611a57906116a3565b9050836001600160601b031682600001516001600160601b03161015611a8f5760405162461bcd60e51b81526004016105da90614509565b81516001600160601b0390859003811683528151808601919081169082161015611acb5760405162461bcd60e51b81526004016105da90614509565b6001600160601b0381168252611ae0836129cf565b6001600160a01b038516600090815260086020526040902055611b02826129cf565b6001600160a01b0380881660008181526008602052604090819020939093559151908a16906000805160206148cd83398151915290611b4290899061471b565b60405180910390a3505050505050505050565b8254600160a01b90046001600160601b0316611b6f6130b8565b6001600160a01b038416600090815260086020526040902054611b91906116a3565b9050611b9b6130d8565b6000611bc48684868a60010160149054906101000a90046001600160601b031689876001612c63565b905030611bcf6130b8565b6001600160a01b038216600090815260086020526040902054611bf1906116a3565b9050826001600160601b031681600001516001600160601b03161015611c295760405162461bcd60e51b81526004016105da90614509565b80518390036001600160601b03168152611c42816129cf565b6001600160a01b038316600090815260086020526040902055611c64856129cf565b6001600160a01b0389166000908152600860205260409081902091909155517fe7b1342ce7f88416536f0a97fd9274421e3718dd094f96e9cefec28f6d7002c190611cb590889060028d019061472f565b60405180910390a160006001600160a01b0316886001600160a01b03166000805160206148cd83398151915288604051611b42919061471b565b60018260400151036001600160401b0316816001600160401b03161461062b5760405162461bcd60e51b81526004016105da90614587565b60006107347fcc8d9dbb126d24ffe7913ca013b4ed4cae09e128eedc4622e4be8004699cf3c27f72079e1ca444dd2cbc0e28bb80962e9f4fbafb3705580b6b9f66186befba0395600186602001518760400151886060015180519060200120611d938a60800151612c6e565b611da18b60a001518b612cd6565b604051602001611db797969594939291906140fa565b60405160208183030381529060405280519060200120612d1d565b81516001600160a01b03163314611dfb5760405162461bcd60e51b81526004016105da906143b0565b6000807f000000000000000000000000a916bc21d2429645585abede4ae00742a16dd1c66001600160a01b0316630296287733886040518363ffffffff1660e01b8152600401611e4c929190613ef3565b604080518083038186803b158015611e6357600080fd5b505afa158015611e77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e9b9190613ae8565b9150915081611ebc5760405162461bcd60e51b81526004016105da90614370565b6020840151429082906001600160401b03610e10840181169181169182111591600191851610611f0557826001600160401b0316886020015185036001600160401b0316111590505b818015611f0f5750805b611f2b5760405162461bcd60e51b81526004016105da9061454b565b876060015115611f4157611f3e89612d32565b98505b600060018a89604001518a600001518b6020015160405160008152602001604052604051611f729493929190614136565b6020604051602081039080840390855afa158015611f94573d6000803e3d6000fd5b5050506020604051035190508860600151158015611fc457508a6001600160a01b0316816001600160a01b031614155b15612028576001611fd48b612d32565b6040808b01518b516020808e015184516000815290910193849052611ff99493614136565b6020604051602081039080840390855afa15801561201b573d6000803e3d6000fd5b5050506020604051035190505b806001600160a01b03168b6001600160a01b0316146120595760405162461bcd60e51b81526004016105da906144b6565b5050505050505050505050565b61206e6130d8565b6120766130d8565b83516001600160601b03161561211e578351678ac7230489e800006001600160601b0390911611156120ba5760405162461bcd60e51b81526004016105da906145e8565b835183516001600160601b03918216911610156120e95760405162461bcd60e51b81526004016105da90614234565b83518351036001600160601b03908116845284511660208201528060035b9081600481111561211457fe5b9052509050610734565b60208401516001600160601b0316156121e957604080518082018252600081526020868101516001600160601b03169082015290516310b4a23d60e01b81526001600160a01b037f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f1216916310b4a23d9161219c918991600401613f53565b600060405180830381600087803b1580156121b657600080fd5b505af11580156121ca573d6000803e3d6000fd5b5050506020808601516001600160601b03169083015250806001612107565b60408401516001600160601b0316156122b35760408051808201825260018152858201516001600160601b0316602082015290516310b4a23d60e01b81526001600160a01b037f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f1216916310b4a23d91612266918991600401613f53565b600060405180830381600087803b15801561228057600080fd5b505af1158015612294573d6000803e3d6000fd5b50505060408501516001600160601b0316602083015250806002612107565b60608401516001600160601b0316156122de5760405162461bcd60e51b81526004016105da906142f3565b949350505050565b60006122f9878787600042876000612c63565b90508215612316576040860180516001016001600160401b031690525b6001600160601b038116156123635785516001600160601b03808316911610156123525760405162461bcd60e51b81526004016105da9061452a565b85518190036001600160601b031686525b61236c866129cf565b6001600160a01b03881660009081526008602052604081209190915582516001600160601b038716919060048111156123a157fe5b905060608160ff16901b82179150606384602001516001600160601b0316901b821791507fe7b1342ce7f88416536f0a97fd9274421e3718dd094f96e9cefec28f6d7002c182876040516123f69291906146e0565b60405180910390a160006001600160a01b0316896001600160a01b03166000805160206148cd83398151915285604051611b42919061471b565b60008082601f8151811061244057fe5b0160209081015160f81c91508110610556578281601f0160ff168151811061246457fe5b016020015160f81c905092915050565b60006107347fcc8d9dbb126d24ffe7913ca013b4ed4cae09e128eedc4622e4be8004699cf3c27f7d1602bfd7297f6720514f0c3dabe77313ce0d25cd5085644e3fcdc5635df66060008660200151876040015188606001518960800151805190602001206124e58b60a00151612c6e565b6124f38c60c001518c612cd6565b604051602001611db79897969594939291906140b5565b6125126130b8565b61251c858561073b565b905061252f858583602001518686612d45565b610b638585611941565b600061254584836118f6565b805460018201549192506001600160601b03600160a01b91829004811692919091041661257330878461132c565b6125808686868585610b63565b7f74c334759f9bfb4a4342d46ed6f4dfb2a3c6b7fe1c7c2288988e8b44bc281b8a8685876040516125b39392919061402f565b60405180910390a1505050505050565b6125cb6130d8565b6125d36130d8565b83516001600160601b031615612651578351678ac7230489e800006001600160601b0390911611156126175760405162461bcd60e51b81526004016105da906145e8565b80602001516001600160601b031683600001516001600160601b031610156120e95760405162461bcd60e51b81526004016105da90614234565b60208401516001600160601b0316156126cf57604080518082018252600081526020868101516001600160601b03169082015290516310b4a23d60e01b81526001600160a01b037f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f1216916310b4a23d9161219c918991600401613f53565b60408401516001600160601b0316156122de5760408051808201825260018152858201516001600160601b0316602082015290516310b4a23d60e01b81526001600160a01b037f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f1216916310b4a23d91612266918991600401613f53565b846001600160a01b0316876001600160a01b0316141561277e5760405162461bcd60e51b81526004016105da9061429a565b8115612799576040860180516001016001600160401b031690525b855183906001600160601b03808316911610156127c85760405162461bcd60e51b81526004016105da90614195565b86516001600160601b03908290038116885285518083019190811690821610156128045760405162461bcd60e51b81526004016105da90614450565b6001600160601b0381168652612819886129cf565b6001600160a01b038a1660009081526008602052604090205561283b866129cf565b6001600160a01b0380891660008181526008602052604090819020939093559151908b16906000805160206148cd83398151915290611b4290869061471b565b6001600160a01b0384166128a15760405162461bcd60e51b81526004016105da90614410565b6128a96130b8565b6001600160a01b0385166000908152600860205260409020546128cb906116a3565b90506128d56130d8565b61139c8683878787866122e6565b6000336001600160a01b037f000000000000000000000000ac0122e9258a85ba5479db764dc8ef91cab08db016141561291e57506001610535565b336001600160a01b037f0000000000000000000000003b4da358199060bcc5a527ab60099fb6a908aae916141561295757506001610535565b336001600160a01b037f000000000000000000000000025dbd03ed18b4b8425af51b4d05f5b00e78208a16141561299057506001610535565b336001600160a01b037f000000000000000000000000e7cd2797ac6f08b5721c7e7fcc991251df5e38841614156129c957506001610535565b50600090565b805160208201516040909201516001600160601b0390911660609290921b6bffffffffffffffffffffffff60601b169190911760c09190911b6001600160c01b0319161790565b612a1e6130d8565b6000612a2984612e20565b9050612a336130d8565b5060408051808201825260ff851681526001600160401b0383166020808301919091526001600160a01b038716600090815260029091529190912054601911612a8e5760405162461bcd60e51b81526004016105da90614334565b6040868101516001600160a01b0387811660009081526002602090815284822080546001810182559083528183208751910180548884015160ff1990911660ff9384161768ffffffffffffffff0019166101006001600160401b0392831602179091558651606081018852918b168252421691810191909152918316938201939093529091600390612b208987611670565b815260208082019290925260409081016000208351815493850151949092015160ff1990931660ff9092169190911768ffffffffffffffff0019166101006001600160401b0390941693909302929092177fffffff0000000000000000000000000000000000000000ffffffffffffffffff16600160481b6001600160a01b03909216919091021790555095945050505050565b612bbc613187565b612bc785308561132c565b612bcf613187565b50506040805160a0810182526001600160a01b0380881682526001600160601b038516602083015285169181019190915260006060820152608081018290529695505050505050565b6001600160a01b038216600090815260016020526040902080546001600160401b03838116600160401b9092041614610aca5760405162461bcd60e51b81526004016105da90614569565b509295945050505050565b60007ff1f7d09b7527273cfd8370620354f0cd9a62e7bd3efaafdeca15664a7b3e045c8260000151836020015184604001518560600151604051602001612cb9959493929190614154565b604051602081830303815290604052805190602001209050919050565b60007ff45b7e63030d0a046d85957a672f9a0806d76fff4cc32355d75f64eb6e83d00882846020015185604001518660600151604051602001611685959493929190614067565b60008282604051602001611685929190613ec4565b600081604051602001612cb99190613e93565b612d53858560200151612ebd565b612d5b613091565b612d6486611202565b80519091508015612d8a575080604001516001600160a01b0316336001600160a01b0316145b612da65760405162461bcd60e51b81526004016105da90614629565b6060612db0612f08565b60405163e17e413160e01b81529091507385ae45a05971170b70744292e2f051c0c49cf9099063e17e413190612df4908a90899087908a9088908b90600401613f85565b60006040518083038186803b158015612e0c57600080fd5b505af4158015612059573d6000803e3d6000fd5b6001600160a01b03811660009081526001602081905260408220805490916001600160401b0380831690910191600160401b900416612e825781546fffffffffffffffff00000000000000001916600160401b6001600160401b038316021782555b815467ffffffffffffffff60801b1916600160801b6001600160401b0383169081029190911767ffffffffffffffff19161790915592915050565b6001600160a01b038216600090815260016020526040902080546001600160401b03838116600160801b9092041614610aca5760405162461bcd60e51b81526004016105da90614431565b60408051600580825260c082019092526060918291906020820160a0803683370190505090503081600081518110612f3c57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000b628bc994e39ce264eca6f6ee1620909816a9f1281600181518110612f8a57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000ac0122e9258a85ba5479db764dc8ef91cab08db081600281518110612fd857fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000003b4da358199060bcc5a527ab60099fb6a908aae98160038151811061302657fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000025dbd03ed18b4b8425af51b4d05f5b00e78208a8160048151811061307457fe5b6001600160a01b0390921660209283029190910190910152905090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b604080516060810182526000808252602082018190529181019190915290565b604080518082019091526000808252602082015290565b6040518060e00160405280600060ff16815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016060815260200161313a613091565b8152602001613147613091565b905290565b6040518060c00160405280600060ff16815260200160006001600160a01b03168152602001600081526020016060815260200161313a613091565b6040805160a081018252600080825260208201819052918101829052606080820192909252608081019190915290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106131f857805160ff1916838001178555613225565b82800160010185558215613225579182015b8281111561322557825182559160200191906001019061320a565b50613231929150613235565b5090565b5b808211156132315760008155600101613236565b80356105568161486d565b80516105568161486d565b600082601f830112613270578081fd5b813561328361327e826147f3565b6147cd565b81815291506020808301908481016060808502870183018810156132a657600080fd5b60005b858110156132cd576132bb8984613686565b855293830193918101916001016132a9565b50505050505092915050565b600082601f8301126132e9578081fd5b81356132f761327e82614812565b915080825283602082850101111561330e57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112613337578081fd5b815161334561327e82614812565b915080825283602082850101111561335c57600080fd5b61336d816020840160208601614841565b5092915050565b60006101808284031215613386578081fd5b61339060c06147cd565b9050813561339d816148a8565b815260208201356133ad8161486d565b60208201526040828101359082015260608201356001600160401b038111156133d557600080fd5b6133e1848285016132d9565b6060830152506133f483608084016134c0565b6080820152613407836101008401613587565b60a082015292915050565b60006101a08284031215613424578081fd5b61342e60e06147cd565b905061343a83836136ca565b8152613449836020840161324a565b602082015261345b836040840161324a565b60408201526060820135606082015260808201356001600160401b0381111561348357600080fd5b61348f848285016132d9565b6080830152506134a28360a084016134c0565b60a08201526134b5836101208401613587565b60c082015292915050565b6000608082840312156134d1578081fd5b6134db60806147cd565b905081356134e8816148b7565b815260208201356134f8816148b7565b6020820152604082013561350b816148b7565b6040820152606082013561351e816148b7565b606082015292915050565b60006080828403121561353a578081fd5b61354460806147cd565b90508151613551816148b7565b81526020820151613561816148b7565b60208201526040820151613574816148b7565b6040820152606082015161351e816148b7565b600060808284031215613598578081fd5b6135a260806147cd565b905081356135af8161486d565b815260208201356135bf81614893565b602082015260408201356135d281614893565b6040820152606082013561351e81614885565b6000608082840312156135f6578081fd5b61360060806147cd565b9050815161360d8161486d565b8152602082015161361d81614893565b6020820152604082015161363081614893565b6040820152606082015161351e81614885565b600060408284031215613654578081fd5b61365e60406147cd565b9050813561366b816148a8565b8152602082013561367b81614893565b602082015292915050565b600060608284031215613697578081fd5b6136a160606147cd565b9050813581526020820135602082015260408201356136bf816148a8565b604082015292915050565b8035610556816148a8565b8051610556816148a8565b6000602082840312156136f1578081fd5b81356107348161486d565b6000806040838503121561370e578081fd5b82356137198161486d565b915060208301356137298161486d565b809150509250929050565b600080600060608486031215613748578081fd5b83356137538161486d565b925060208401356137638161486d565b929592945050506040919091013590565b60008060008060006080868803121561378b578283fd5b85356137968161486d565b945060208601356137a68161486d565b93506040860135925060608601356001600160401b03808211156137c8578283fd5b818801915088601f8301126137db578283fd5b8135818111156137e9578384fd5b8960208285010111156137fa578384fd5b9699959850939650602001949392505050565b6000806040838503121561381f578182fd5b823561382a8161486d565b915060208301356001600160401b03811115613844578182fd5b613850858286016132d9565b9150509250929050565b6000806060838503121561386c578182fd5b82356138778161486d565b91506138868460208501613643565b90509250929050565b60008060008060e085870312156138a4578182fd5b84356138af8161486d565b93506138be8660208701613643565b925060608501356001600160401b038111156138d8578283fd5b6138e4878288016132d9565b9250506138f48660808701613686565b905092959194509250565b6000808284036060811215613912578283fd5b833561391d8161486d565b92506040601f1982011215613930578182fd5b5061393b60406147cd565b6020840135613949816148a8565b81526040840135613959816148b7565b6020820152919491935090915050565b6000806040838503121561397b578182fd5b82356139868161486d565b946020939093013593505050565b600080604083850312156139a6578182fd5b82356139b18161486d565b9150602083013561372981614893565b600080604083850312156139d3578182fd5b82356001600160401b03808211156139e9578384fd5b818501915085601f8301126139fc578384fd5b8135613a0a61327e826147f3565b81815260208082019190858101885b85811015613a4257613a308c8484358b0101613374565b85529382019390820190600101613a19565b50919750880135945050505080821115613a5a578283fd5b5061385085828601613260565b60008060408385031215613a79578182fd5b82356001600160401b0380821115613a8f578384fd5b818501915085601f830112613aa2578384fd5b8135613ab061327e826147f3565b81815260208082019190858101885b85811015613a4257613ad68c8484358b0101613412565b85529382019390820190600101613abf565b60008060408385031215613afa578182fd5b8251613b0581614885565b6020939093015192949293505050565b600060208284031215613b26578081fd5b81516001600160401b0380821115613b3c578283fd5b908301906101808286031215613b50578283fd5b613b5a60c06147cd565b8251613b65816148a8565b8152613b748660208501613255565b602082015260408301516040820152606083015182811115613b94578485fd5b613ba087828601613327565b606083015250613bb38660808501613529565b6080820152613bc68661010085016135e5565b60a082015295945050505050565b60008060808385031215613be6578182fd5b82356001600160401b03811115613bfb578283fd5b613c0785828601613374565b9250506138868460208501613686565b600060208284031215613c28578081fd5b81516001600160401b0380821115613c3e578283fd5b908301906101a08286031215613c52578283fd5b613c5c60e06147cd565b613c6686846136d5565b8152613c758660208501613255565b6020820152613c878660408501613255565b604082015260608301516060820152608083015182811115613ca7578485fd5b613cb387828601613327565b608083015250613cc68660a08501613529565b60a0820152613cd98661012085016135e5565b60c082015295945050505050565b60008060808385031215613cf9578182fd5b82356001600160401b03811115613d0e578283fd5b613c0785828601613412565b600060808284031215613d2b578081fd5b613d3560806147cd565b8251613d4081614885565b81526020830151613d5081614885565b60208201526040830151613d638161486d565b6040820152606083015163ffffffff81168114613d7e578283fd5b60608201529392505050565b60008060408385031215613d9c578182fd5b8235915060208301356001600160401b03811115613844578182fd5b600060208284031215613dc9578081fd5b815161073481614893565b60008151808452613dec816020860160208601614841565b601f01601f19169290920160200192915050565b805160ff1682526020808201516001600160401b0316908301526040908101516001600160a01b0316910152565b8051151582526020808201511515908301526040808201516001600160a01b03169083015260609081015163ffffffff16910152565b60609290921b6bffffffffffffffffffffffff1916825260c01b6001600160c01b0319166014820152601c0190565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b61190160f01b81526002810192909252602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03959095168552835160ff16602080870191909152909301516001600160401b031660408501526060840191909152608083015260a082015260c00190565b6001600160a01b03929092168252805160ff1660208084019190915201516001600160601b0316604082015260600190565b600061016060018060a01b03808a16845260206001600160401b038a1681860152613fb3604086018a613e2e565b8260c0860152613fc583860189613dd4565b85810360e08701528751808252828901945090820190855b81811015613ffb578551851683529483019491830191600101613fdd565b50508094505085516101008601528086015161012086015250505060ff604084015116610140830152979650505050505050565b6001600160a01b039390931683526001600160401b0391909116602083015260ff16604082015260600190565b901515815260200190565b9485526001600160a01b039390931660208501526001600160401b0391821660408501521660608301521515608082015260a00190565b9182526001600160401b0316602082015260400190565b97885260ff9690961660208801526001600160a01b039485166040880152929093166060860152608085015260a084019190915260c083015260e08201526101000190565b96875260ff9590951660208701526001600160a01b039390931660408601526060850191909152608084015260a083015260c082015260e00190565b93845260ff9290921660208401526040830152606082015260800190565b9485526001600160601b03938416602086015291831660408501528216606084015216608082015260a00190565b6000602082526107346020830184613dd4565b602080825260089082015267045524332302d31360c41b604082015260600190565b60208082526007908201526622a9219918169b60c91b604082015260600190565b60208082526004908201526350422d3160e01b604082015260600190565b602080825260069082015265445542492d3160d01b604082015260600190565b6020808252600490820152632821169960e11b604082015260600190565b602080825260069082015265445542492d3760d01b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526008908201526745524332302d313960c01b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b602080825260069082015265088aa84925a760d31b604082015260600190565b60208082526007908201526645524332302d3760c81b604082015260600190565b60208082526004908201526350422d3360e01b604082015260600190565b60208082526004908201526350422d3760e01b604082015260600190565b60208082526004908201526341422d3360e01b604082015260600190565b60208082526008908201526745524332302d313760c01b604082015260600190565b60208082526004908201526320a1169960e11b604082015260600190565b60208082526008908201526745524332302d313560c01b604082015260600190565b602080825260069082015265222aa124969960d11b604082015260600190565b60208082526007908201526608aa48664605a760cb1b604082015260600190565b602080825260059082015264050422d31360dc1b604082015260600190565b60208082526008908201526722a921991816989960c11b604082015260600190565b60208082526008908201526722a921991816989b60c11b604082015260600190565b60208082526008908201526745524332302d313360c01b604082015260600190565b60208082526004908201526341422d3560e01b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526007908201526622a9219918169960c91b604082015260600190565b60208082526007908201526645524332302d3960c81b604082015260600190565b60208082526004908201526310508b4d60e21b604082015260600190565b60208082526004908201526350422d3960e01b604082015260600190565b60208082526007908201526645524332302d3560c81b604082015260600190565b602080825260069082015265222aa124969b60d11b604082015260600190565b602080825260069082015265445542492d3360d01b604082015260600190565b602080825260069082015265445542492d3560d01b604082015260600190565b60208082526007908201526645524332302d3160c81b604082015260600190565b6020808252600490820152632821169b60e11b604082015260600190565b81516001600160401b039081168252602080840151821690830152604092830151169181019190915260600190565b606081016105568284613e00565b60e081016146928285613e00565b6107346060830184613e2e565b81516001600160601b039081168252602080840151909116908201526040918201516001600160401b03169181019190915260600190565b90815260200190565b6000838252604060208301526122de6040830184613dd4565b6001600160401b0391909116815260200190565b60ff91909116815260200190565b6001600160601b0391909116815260200190565b6000604082016001600160601b038516835260206040818501528285546001808216600081146147665760018114614784576147bf565b60028304607f16865260ff19831660608901526080880193506147bf565b6002830461479281886146d7565b61479b8b614835565b895b838110156147b65781548382015290850190880161479d565b91909101955050505b509198975050505050505050565b6040518181016001600160401b03811182821017156147eb57600080fd5b604052919050565b60006001600160401b03821115614808578081fd5b5060209081020190565b60006001600160401b03821115614827578081fd5b50601f01601f191660200190565b60009081526020902090565b60005b8381101561485c578181015183820152602001614844565b83811115610f135750506000910152565b6001600160a01b038116811461488257600080fd5b50565b801515811461488257600080fd5b6001600160401b038116811461488257600080fd5b60ff8116811461488257600080fd5b6001600160601b038116811461488257600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220fead6c60ce95b63b6730927ed7e3e8d7e2d20fc92757ccec5ef000b845349d3e64736f6c634300060c0033
[ 12, 5, 4, 7 ]
0xF3D751855b21bf0b17C229106f6C428C838C4917
/** * ██▓▓▒▒░░ * ██▓▓▒▒░░ * ██▓▓▒▒░░ * ██▓▓▒▒░░ * ██▓▓▒▒░░ * ██▓▓▒▒░░ * ██▓▓▒▒░░ * ██▓▓▒▒░░ * Rainbow Grid * Kim Asendorf * 2021 */ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; contract RainbowGrid is ERC721Enumerable, ERC721URIStorage, ERC721Burnable, ReentrancyGuard, Pausable, Ownable { using SafeMath for uint256; using Strings for uint256; string public baseURI = "ipfs://QmSGvRD4QpgYtzc9EzgXyCf6Ky89b3CfbE6m3UXyj9EYF3/"; bool[] availableTokens = new bool[](54); uint256 public mintPrice = 0.25 ether; address payable public withdrawalAddress; event onMint(address minter, uint256 tokenId); constructor(address payable _withdrawalAddress) ERC721("Rainbow Grid, Kim Asendorf", "ASDFRG") { withdrawalAddress = _withdrawalAddress; for (uint256 i = 0; i < availableTokens.length; i++) { availableTokens[i] = true; } } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } function mint(uint256 tokenId) public payable whenNotPaused nonReentrant { require(mintPrice == msg.value, "Wrong amount of Ethereum supplied."); safeMint(tokenId); } function creatorMint(uint256 tokenId) public onlyOwner { safeMint(tokenId); } function safeMint(uint256 tokenId) private { require(tokenId >= 0 && tokenId < availableTokens.length, "This token doesn't exist."); require(availableTokens[tokenId], "This token has already been minted."); availableTokens[tokenId] = false; _safeMint(msg.sender, tokenId); emit onMint(msg.sender, tokenId); } function resetTokenAvailable(uint256 tokenId) public onlyOwner { require(tokenId >= 0 && tokenId < availableTokens.length, "This token doesn't exist."); require(!_exists(tokenId), "Token has already been minted and can not be resetted."); availableTokens[tokenId] = true; } function withdraw() public onlyOwner { Address.sendValue(withdrawalAddress, address(this).balance); } function getBaseURI() external view returns (string memory) { return baseURI; } function getAvailableTokens() external view returns (bool[] memory) { return availableTokens; } function getBalance() public view returns (uint256) { return address(this).balance; } function getMintPrice() external view returns (uint256) { return mintPrice; } function setMintPrice(uint256 _mintPrice) public onlyOwner { mintPrice = _mintPrice; } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return string(abi.encodePacked(baseURI, Strings.toString(tokenId), ".json")); } function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721URIStorage.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "../../../utils/Context.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106102045760003560e01c80636c0360eb11610118578063a7f93ebd116100a0578063e985e9c51161006f578063e985e9c514610724578063f2bcd02214610761578063f2fde38b1461078c578063f4a0a528146107b5578063fb6027b6146107de57610204565b8063a7f93ebd14610668578063b88d4fde14610693578063c87b56dd146106bc578063e35568cb146106f957610204565b80638456cb59116100e75780638456cb59146105b65780638da5cb5b146105cd57806395d89b41146105f8578063a0712d6814610623578063a22cb4651461063f57610204565b80636c0360eb1461050c57806370a0823114610537578063714c539814610574578063715018a61461059f57610204565b80633ccfd60b1161019b5780634f6ccce71161016a5780634f6ccce7146104135780635bf14b46146104505780635c975abb146104795780636352211e146104a45780636817c76c146104e157610204565b80633ccfd60b146103935780633f4ba83a146103aa57806342842e0e146103c157806342966c68146103ea57610204565b806312065fe0116101d757806312065fe0146102d757806318160ddd1461030257806323b872dd1461032d5780632f745c591461035657610204565b806301ffc9a71461020957806306fdde0314610246578063081812fc14610271578063095ea7b3146102ae575b600080fd5b34801561021557600080fd5b50610230600480360381019061022b91906133d1565b610807565b60405161023d9190614106565b60405180910390f35b34801561025257600080fd5b5061025b610819565b6040516102689190614121565b60405180910390f35b34801561027d57600080fd5b5061029860048036038101906102939190613423565b6108ab565b6040516102a59190614039565b60405180910390f35b3480156102ba57600080fd5b506102d560048036038101906102d09190613395565b610930565b005b3480156102e357600080fd5b506102ec610a48565b6040516102f991906144a3565b60405180910390f35b34801561030e57600080fd5b50610317610a50565b60405161032491906144a3565b60405180910390f35b34801561033957600080fd5b50610354600480360381019061034f919061328f565b610a5d565b005b34801561036257600080fd5b5061037d60048036038101906103789190613395565b610abd565b60405161038a91906144a3565b60405180910390f35b34801561039f57600080fd5b506103a8610b62565b005b3480156103b657600080fd5b506103bf610c0c565b005b3480156103cd57600080fd5b506103e860048036038101906103e3919061328f565b610c92565b005b3480156103f657600080fd5b50610411600480360381019061040c9190613423565b610cb2565b005b34801561041f57600080fd5b5061043a60048036038101906104359190613423565b610d0e565b60405161044791906144a3565b60405180910390f35b34801561045c57600080fd5b5061047760048036038101906104729190613423565b610da5565b005b34801561048557600080fd5b5061048e610f26565b60405161049b9190614106565b60405180910390f35b3480156104b057600080fd5b506104cb60048036038101906104c69190613423565b610f3d565b6040516104d89190614039565b60405180910390f35b3480156104ed57600080fd5b506104f6610fef565b60405161050391906144a3565b60405180910390f35b34801561051857600080fd5b50610521610ff5565b60405161052e9190614121565b60405180910390f35b34801561054357600080fd5b5061055e6004803603810190610559919061322a565b611083565b60405161056b91906144a3565b60405180910390f35b34801561058057600080fd5b5061058961113b565b6040516105969190614121565b60405180910390f35b3480156105ab57600080fd5b506105b46111cd565b005b3480156105c257600080fd5b506105cb611255565b005b3480156105d957600080fd5b506105e26112db565b6040516105ef9190614039565b60405180910390f35b34801561060457600080fd5b5061060d611305565b60405161061a9190614121565b60405180910390f35b61063d60048036038101906106389190613423565b611397565b005b34801561064b57600080fd5b5061066660048036038101906106619190613359565b611485565b005b34801561067457600080fd5b5061067d61149b565b60405161068a91906144a3565b60405180910390f35b34801561069f57600080fd5b506106ba60048036038101906106b591906132de565b6114a5565b005b3480156106c857600080fd5b506106e360048036038101906106de9190613423565b611507565b6040516106f09190614121565b60405180910390f35b34801561070557600080fd5b5061070e61153b565b60405161071b91906140e4565b60405180910390f35b34801561073057600080fd5b5061074b60048036038101906107469190613253565b6115b8565b6040516107589190614106565b60405180910390f35b34801561076d57600080fd5b5061077661164c565b6040516107839190614054565b60405180910390f35b34801561079857600080fd5b506107b360048036038101906107ae919061322a565b611672565b005b3480156107c157600080fd5b506107dc60048036038101906107d79190613423565b61176a565b005b3480156107ea57600080fd5b5061080560048036038101906108009190613423565b6117f0565b005b600061081282611878565b9050919050565b6060600080546108289061473e565b80601f01602080910402602001604051908101604052809291908181526020018280546108549061473e565b80156108a15780601f10610876576101008083540402835291602001916108a1565b820191906000526020600020905b81548152906001019060200180831161088457829003601f168201915b5050505050905090565b60006108b6826118f2565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90614343565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061093b82610f3d565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a3906143c3565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166109cb61195e565b73ffffffffffffffffffffffffffffffffffffffff1614806109fa57506109f9816109f461195e565b6115b8565b5b610a39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a30906142c3565b60405180910390fd5b610a438383611966565b505050565b600047905090565b6000600880549050905090565b610a6e610a6861195e565b82611a1f565b610aad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa4906143e3565b60405180910390fd5b610ab8838383611afd565b505050565b6000610ac883611083565b8210610b09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0090614163565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610b6a61195e565b73ffffffffffffffffffffffffffffffffffffffff16610b886112db565b73ffffffffffffffffffffffffffffffffffffffff1614610bde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd590614363565b60405180910390fd5b610c0a601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1647611d59565b565b610c1461195e565b73ffffffffffffffffffffffffffffffffffffffff16610c326112db565b73ffffffffffffffffffffffffffffffffffffffff1614610c88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7f90614363565b60405180910390fd5b610c90611e4d565b565b610cad838383604051806020016040528060008152506114a5565b505050565b610cc3610cbd61195e565b82611a1f565b610d02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cf990614483565b60405180910390fd5b610d0b81611eef565b50565b6000610d18610a50565b8210610d59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5090614403565b60405180910390fd5b60088281548110610d93577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610dad61195e565b73ffffffffffffffffffffffffffffffffffffffff16610dcb6112db565b73ffffffffffffffffffffffffffffffffffffffff1614610e21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1890614363565b60405180910390fd5b60008110158015610e365750600e8054905081105b610e75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6c906143a3565b60405180910390fd5b610e7e816118f2565b15610ebe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb590614423565b60405180910390fd5b6001600e8281548110610efa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090602091828204019190066101000a81548160ff02191690831515021790555050565b6000600c60009054906101000a900460ff16905090565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610fe6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fdd90614303565b60405180910390fd5b80915050919050565b600f5481565b600d80546110029061473e565b80601f016020809104026020016040519081016040528092919081815260200182805461102e9061473e565b801561107b5780601f106110505761010080835404028352916020019161107b565b820191906000526020600020905b81548152906001019060200180831161105e57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110f4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110eb906142e3565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600d805461114a9061473e565b80601f01602080910402602001604051908101604052809291908181526020018280546111769061473e565b80156111c35780601f10611198576101008083540402835291602001916111c3565b820191906000526020600020905b8154815290600101906020018083116111a657829003601f168201915b5050505050905090565b6111d561195e565b73ffffffffffffffffffffffffffffffffffffffff166111f36112db565b73ffffffffffffffffffffffffffffffffffffffff1614611249576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124090614363565b60405180910390fd5b6112536000611efb565b565b61125d61195e565b73ffffffffffffffffffffffffffffffffffffffff1661127b6112db565b73ffffffffffffffffffffffffffffffffffffffff16146112d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c890614363565b60405180910390fd5b6112d9611fc1565b565b6000600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546113149061473e565b80601f01602080910402602001604051908101604052809291908181526020018280546113409061473e565b801561138d5780601f106113625761010080835404028352916020019161138d565b820191906000526020600020905b81548152906001019060200180831161137057829003601f168201915b5050505050905090565b61139f610f26565b156113df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d6906142a3565b60405180910390fd5b6002600b541415611425576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141c90614463565b60405180910390fd5b6002600b8190555034600f5414611471576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146890614223565b60405180910390fd5b61147a81612064565b6001600b8190555050565b61149761149061195e565b83836121fc565b5050565b6000600f54905090565b6114b66114b061195e565b83611a1f565b6114f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ec906143e3565b60405180910390fd5b61150184848484612369565b50505050565b6060600d611514836123c5565b604051602001611525929190613ff5565b6040516020818303038152906040529050919050565b6060600e8054806020026020016040519081016040528092919081815260200182805480156115ae57602002820191906000526020600020906000905b82829054906101000a900460ff161515815260200190600101906020826000010492830192600103820291508084116115785790505b5050505050905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61167a61195e565b73ffffffffffffffffffffffffffffffffffffffff166116986112db565b73ffffffffffffffffffffffffffffffffffffffff16146116ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116e590614363565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561175e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611755906141a3565b60405180910390fd5b61176781611efb565b50565b61177261195e565b73ffffffffffffffffffffffffffffffffffffffff166117906112db565b73ffffffffffffffffffffffffffffffffffffffff16146117e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117dd90614363565b60405180910390fd5b80600f8190555050565b6117f861195e565b73ffffffffffffffffffffffffffffffffffffffff166118166112db565b73ffffffffffffffffffffffffffffffffffffffff161461186c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186390614363565b60405180910390fd5b61187581612064565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806118eb57506118ea82612572565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166119d983610f3d565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611a2a826118f2565b611a69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6090614283565b60405180910390fd5b6000611a7483610f3d565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ae357508373ffffffffffffffffffffffffffffffffffffffff16611acb846108ab565b73ffffffffffffffffffffffffffffffffffffffff16145b80611af45750611af381856115b8565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611b1d82610f3d565b73ffffffffffffffffffffffffffffffffffffffff1614611b73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6a90614383565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611be3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bda906141e3565b60405180910390fd5b611bee838383612654565b611bf9600082611966565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c499190614642565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ca091906145bb565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b80471015611d9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d9390614263565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1682604051611dc290614024565b60006040518083038185875af1925050503d8060008114611dff576040519150601f19603f3d011682016040523d82523d6000602084013e611e04565b606091505b5050905080611e48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e3f90614243565b60405180910390fd5b505050565b611e55610f26565b611e94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e8b90614143565b60405180910390fd5b6000600c60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611ed861195e565b604051611ee59190614039565b60405180910390a1565b611ef8816126ac565b50565b6000600c60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600c60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b611fc9610f26565b15612009576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612000906142a3565b60405180910390fd5b6001600c60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861204d61195e565b60405161205a9190614039565b60405180910390a1565b600081101580156120795750600e8054905081105b6120b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120af906143a3565b60405180910390fd5b600e81815481106120f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff16612151576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161214890614443565b60405180910390fd5b6000600e828154811061218d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002090602091828204019190066101000a81548160ff0219169083151502179055506121c033826126ff565b7f0f632fd389970cd3b065f85dce83c297194646c14c7ef2e302cb3307b04c772033826040516121f19291906140bb565b60405180910390a150565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561226b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226290614203565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161235c9190614106565b60405180910390a3505050565b612374848484611afd565b6123808484848461271d565b6123bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123b690614183565b60405180910390fd5b50505050565b6060600082141561240d576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061256d565b600082905060005b6000821461243f57808061242890614770565b915050600a826124389190614611565b9150612415565b60008167ffffffffffffffff811115612481577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156124b35781602001600182028036833780820191505090505b5090505b60008514612566576001826124cc9190614642565b9150600a856124db91906147b9565b60306124e791906145bb565b60f81b818381518110612523577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561255f9190614611565b94506124b7565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061263d57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061264d575061264c826128b4565b5b9050919050565b61265c610f26565b1561269c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612693906142a3565b60405180910390fd5b6126a783838361291e565b505050565b6126b581612a32565b6000600a600083815260200190815260200160002080546126d59061473e565b9050146126fc57600a600082815260200190815260200160002060006126fb91906130fc565b5b50565b612719828260405180602001604052806000815250612b43565b5050565b600061273e8473ffffffffffffffffffffffffffffffffffffffff16612b9e565b156128a7578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261276761195e565b8786866040518563ffffffff1660e01b8152600401612789949392919061406f565b602060405180830381600087803b1580156127a357600080fd5b505af19250505080156127d457506040513d601f19601f820116820180604052508101906127d191906133fa565b60015b612857573d8060008114612804576040519150601f19603f3d011682016040523d82523d6000602084013e612809565b606091505b5060008151141561284f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161284690614183565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506128ac565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612929838383612bb1565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561296c5761296781612bb6565b6129ab565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146129aa576129a98382612bff565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129ee576129e981612d6c565b612a2d565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612a2c57612a2b8282612eaf565b5b5b505050565b6000612a3d82610f3d565b9050612a4b81600084612654565b612a56600083611966565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612aa69190614642565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b612b4d8383612f2e565b612b5a600084848461271d565b612b99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b9090614183565b60405180910390fd5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612c0c84611083565b612c169190614642565b9050600060076000848152602001908152602001600020549050818114612cfb576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612d809190614642565b9050600060096000848152602001908152602001600020549050600060088381548110612dd6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612e1e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612e93577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612eba83611083565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612f9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f9590614323565b60405180910390fd5b612fa7816118f2565b15612fe7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612fde906141c3565b60405180910390fd5b612ff360008383612654565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461304391906145bb565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b5080546131089061473e565b6000825580601f1061311a5750613139565b601f016020900490600052602060002090810190613138919061313c565b5b50565b5b8082111561315557600081600090555060010161313d565b5090565b600061316c613167846144ef565b6144be565b90508281526020810184848401111561318457600080fd5b61318f8482856146fc565b509392505050565b6000813590506131a6816148b7565b92915050565b6000813590506131bb816148ce565b92915050565b6000813590506131d0816148e5565b92915050565b6000815190506131e5816148e5565b92915050565b600082601f8301126131fc57600080fd5b813561320c848260208601613159565b91505092915050565b600081359050613224816148fc565b92915050565b60006020828403121561323c57600080fd5b600061324a84828501613197565b91505092915050565b6000806040838503121561326657600080fd5b600061327485828601613197565b925050602061328585828601613197565b9150509250929050565b6000806000606084860312156132a457600080fd5b60006132b286828701613197565b93505060206132c386828701613197565b92505060406132d486828701613215565b9150509250925092565b600080600080608085870312156132f457600080fd5b600061330287828801613197565b945050602061331387828801613197565b935050604061332487828801613215565b925050606085013567ffffffffffffffff81111561334157600080fd5b61334d878288016131eb565b91505092959194509250565b6000806040838503121561336c57600080fd5b600061337a85828601613197565b925050602061338b858286016131ac565b9150509250929050565b600080604083850312156133a857600080fd5b60006133b685828601613197565b92505060206133c785828601613215565b9150509250929050565b6000602082840312156133e357600080fd5b60006133f1848285016131c1565b91505092915050565b60006020828403121561340c57600080fd5b600061341a848285016131d6565b91505092915050565b60006020828403121561343557600080fd5b600061344384828501613215565b91505092915050565b600061345883836134e0565b60208301905092915050565b61346d81614688565b82525050565b61347c81614676565b82525050565b600061348d82614544565b6134978185614572565b93506134a28361451f565b8060005b838110156134d35781516134ba888261344c565b97506134c583614565565b9250506001810190506134a6565b5085935050505092915050565b6134e98161469a565b82525050565b6134f88161469a565b82525050565b60006135098261454f565b6135138185614583565b935061352381856020860161470b565b61352c816148a6565b840191505092915050565b60006135428261455a565b61354c818561459f565b935061355c81856020860161470b565b613565816148a6565b840191505092915050565b600061357b8261455a565b61358581856145b0565b935061359581856020860161470b565b80840191505092915050565b600081546135ae8161473e565b6135b881866145b0565b945060018216600081146135d357600181146135e457613617565b60ff19831686528186019350613617565b6135ed8561452f565b60005b8381101561360f578154818901526001820191506020810190506135f0565b838801955050505b50505092915050565b600061362d60148361459f565b91507f5061757361626c653a206e6f74207061757365640000000000000000000000006000830152602082019050919050565b600061366d602b8361459f565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b60006136d360328361459f565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b600061373960268361459f565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061379f601c8361459f565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b60006137df60248361459f565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061384560198361459f565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b600061388560228361459f565b91507f57726f6e6720616d6f756e74206f6620457468657265756d20737570706c696560008301527f642e0000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006138eb603a8361459f565b91507f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008301527f6563697069656e74206d617920686176652072657665727465640000000000006020830152604082019050919050565b6000613951601d8361459f565b91507f416464726573733a20696e73756666696369656e742062616c616e63650000006000830152602082019050919050565b6000613991602c8361459f565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b60006139f760108361459f565b91507f5061757361626c653a20706175736564000000000000000000000000000000006000830152602082019050919050565b6000613a3760388361459f565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000613a9d602a8361459f565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000613b0360298361459f565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613b6960208361459f565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000613ba9602c8361459f565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613c0f6005836145b0565b91507f2e6a736f6e0000000000000000000000000000000000000000000000000000006000830152600582019050919050565b6000613c4f60208361459f565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613c8f60298361459f565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613cf560198361459f565b91507f5468697320746f6b656e20646f65736e27742065786973742e000000000000006000830152602082019050919050565b6000613d3560218361459f565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613d9b600083614594565b9150600082019050919050565b6000613db560318361459f565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000613e1b602c8361459f565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6000613e8160368361459f565b91507f546f6b656e2068617320616c7265616479206265656e206d696e74656420616e60008301527f642063616e206e6f742062652072657365747465642e000000000000000000006020830152604082019050919050565b6000613ee760238361459f565b91507f5468697320746f6b656e2068617320616c7265616479206265656e206d696e7460008301527f65642e00000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613f4d601f8361459f565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b6000613f8d60308361459f565b91507f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f766564000000000000000000000000000000006020830152604082019050919050565b613fef816146f2565b82525050565b600061400182856135a1565b915061400d8284613570565b915061401882613c02565b91508190509392505050565b600061402f82613d8e565b9150819050919050565b600060208201905061404e6000830184613473565b92915050565b60006020820190506140696000830184613464565b92915050565b60006080820190506140846000830187613473565b6140916020830186613473565b61409e6040830185613fe6565b81810360608301526140b081846134fe565b905095945050505050565b60006040820190506140d06000830185613473565b6140dd6020830184613fe6565b9392505050565b600060208201905081810360008301526140fe8184613482565b905092915050565b600060208201905061411b60008301846134ef565b92915050565b6000602082019050818103600083015261413b8184613537565b905092915050565b6000602082019050818103600083015261415c81613620565b9050919050565b6000602082019050818103600083015261417c81613660565b9050919050565b6000602082019050818103600083015261419c816136c6565b9050919050565b600060208201905081810360008301526141bc8161372c565b9050919050565b600060208201905081810360008301526141dc81613792565b9050919050565b600060208201905081810360008301526141fc816137d2565b9050919050565b6000602082019050818103600083015261421c81613838565b9050919050565b6000602082019050818103600083015261423c81613878565b9050919050565b6000602082019050818103600083015261425c816138de565b9050919050565b6000602082019050818103600083015261427c81613944565b9050919050565b6000602082019050818103600083015261429c81613984565b9050919050565b600060208201905081810360008301526142bc816139ea565b9050919050565b600060208201905081810360008301526142dc81613a2a565b9050919050565b600060208201905081810360008301526142fc81613a90565b9050919050565b6000602082019050818103600083015261431c81613af6565b9050919050565b6000602082019050818103600083015261433c81613b5c565b9050919050565b6000602082019050818103600083015261435c81613b9c565b9050919050565b6000602082019050818103600083015261437c81613c42565b9050919050565b6000602082019050818103600083015261439c81613c82565b9050919050565b600060208201905081810360008301526143bc81613ce8565b9050919050565b600060208201905081810360008301526143dc81613d28565b9050919050565b600060208201905081810360008301526143fc81613da8565b9050919050565b6000602082019050818103600083015261441c81613e0e565b9050919050565b6000602082019050818103600083015261443c81613e74565b9050919050565b6000602082019050818103600083015261445c81613eda565b9050919050565b6000602082019050818103600083015261447c81613f40565b9050919050565b6000602082019050818103600083015261449c81613f80565b9050919050565b60006020820190506144b86000830184613fe6565b92915050565b6000604051905081810181811067ffffffffffffffff821117156144e5576144e4614877565b5b8060405250919050565b600067ffffffffffffffff82111561450a57614509614877565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006145c6826146f2565b91506145d1836146f2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614606576146056147ea565b5b828201905092915050565b600061461c826146f2565b9150614627836146f2565b92508261463757614636614819565b5b828204905092915050565b600061464d826146f2565b9150614658836146f2565b92508282101561466b5761466a6147ea565b5b828203905092915050565b6000614681826146d2565b9050919050565b6000614693826146d2565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561472957808201518184015260208101905061470e565b83811115614738576000848401525b50505050565b6000600282049050600182168061475657607f821691505b6020821081141561476a57614769614848565b5b50919050565b600061477b826146f2565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156147ae576147ad6147ea565b5b600182019050919050565b60006147c4826146f2565b91506147cf836146f2565b9250826147df576147de614819565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6148c081614676565b81146148cb57600080fd5b50565b6148d78161469a565b81146148e257600080fd5b50565b6148ee816146a6565b81146148f957600080fd5b50565b614905816146f2565b811461491057600080fd5b5056fea2646970667358221220febe0c3c9beb9659ddb37356f52b959e97bad56f829e74e6aa594d99d816ecff64736f6c63430008000033
[ 5, 19 ]
0xf3d7917fd854dd5392f4afb4e46982470e8fa190
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 888 888 d8b // 888 888 Y8P // 888 888 // .d8888b .d88b. 88888b.d88b. .d88b. 888888 88888b. 888 88888b. .d88b. // 88K d88""88b 888 "888 "88b d8P Y8b 888 888 "88b 888 888 "88b d88P"88b // "Y8888b. 888 888 888 888 888 88888888 888 888 888 888 888 888 888 888 // X88 Y88..88P 888 888 888 Y8b. Y88b. 888 888 888 888 888 Y88b 888 // 88888P' "Y88P" 888 888 888 "Y8888 "Y888 888 888 888 888 888 "Y88888 // 888 // Y8b d88P // "Y88P" import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract something{ //something bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212207e10ca8b05329b73e6a0f6c24e0b0ecdfb66ca4559a56448585e65d84512091064736f6c63430008070033
[ 5 ]
0xf3d7aa957f5cd4e3b8947b6acb88f2b8fd9a2e88
// SPDX-License-Identifier: MIT // File: contracts/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: contracts/Ownable.sol // OpenZeppelin Contracts v4.4.0 (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: contracts/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/MultiBeneficiaryLock.sol pragma solidity ^0.8.0; /** * A gas optimized implementation of a vesting contract for tokens according to a predetermined vesting schedule * for multiple beneficiaries. Beneficiaries can choose how often they invoke release() to receive the unlocked * tokens. There are several steps to use this contract * - construction with token address, length of vesting period, and release interval * - init of the beneficiaries with their respective amounts * - launch of the contract when the launch date is known and after enough tokens are received. */ contract MultiBeneficiaryLock is Ownable { IERC20 private immutable token; uint32 private immutable period; uint32 private immutable interval; uint256 private start; uint256 private totalTokens; struct Balance { uint256 released; uint256 total; } mapping(address => Balance) private balance; modifier notLaunched { require(start == 0, "MBL01"); _; } modifier launched { require(start > 0, "MBL02"); _; } /** * Construct a MultiBeneficiary lock contract that has the specified vesting period in days * and a release interval in days when new tokens prorata become available. */ constructor(IERC20 tokenAddress, uint32 periodDays, uint32 intervalDays) { require(intervalDays <= periodDays, "MBL03"); token = tokenAddress; period = periodDays; interval = intervalDays; } /** * Initialize beneficiaries. Provide the list of beneficiaries for this lock contract and their respective * balances. Only the owner can call this function. * As this is a gas intensive method for large arrays, check for duplicate addresses is left out. It is the * responsibility of the owner to prevent duplicates which can be validated by calling checkInitBeneficiaries upfront. */ function initBeneficiaries(address[] calldata addresses, uint256[] calldata amounts) external onlyOwner notLaunched { require(totalTokens == 0, "MBL04"); require(addresses.length == amounts.length, "MBL05"); uint256 total = 0; for (uint256 i=0; i < addresses.length; i++) { total = total + amounts[i]; balance[addresses[i]] = Balance(0, amounts[i]); } totalTokens = total; } /** * Check that the given list of beneficiaries is sane. Gasless check which can be called before initBeneficiaries. */ function checkInitBeneficiaries(address[] calldata addresses, uint256[] calldata amounts) external view onlyOwner notLaunched returns (uint256){ require(totalTokens == 0, "MBL04"); require(addresses.length == amounts.length, "MBL05"); uint256 total = 0; for (uint256 i=0; i < addresses.length; i++) { total = total + amounts[i]; require(amounts[i] > 0, "MBL06"); for (uint256 j = i + 1; j < addresses.length; j++) { require(addresses[i] != addresses[j], "MBL07"); } } return total; } /** * Return the minium amount of tokens that is required for the contract to be launched * only relevant after init. */ function tokenCountOnLaunch() external view returns (uint256) { return totalTokens; } /** * Return if all preconditions are met for the lock contract to launch: * not launched yet, initialized and token balance enough. */ function readyForLaunch() external view returns (bool) { return (start == 0) && (totalTokens > 0) && (token.balanceOf(address(this)) >= totalTokens); } /** * Launch the contract given a start block time as the basis for the vesting period. * when blocktime reaches startBlocktime, the first interval wait for release starts. * blocktime in seconds since epoch. */ function launch(uint256 startBlocktime) external notLaunched onlyOwner { require(startBlocktime > 0, "MBL08"); require(totalTokens > 0, "MBL09"); require(token.balanceOf(address(this)) >= totalTokens, "MBL10"); start = startBlocktime; } /** * @return the token being held. */ function erc20() external view returns (IERC20) { return token; } /** * @return number of tokens still locked up for a particular beneficiary */ function locked(address holder) external view returns (uint256){ return balance[holder].total - balance[holder].released - amountCanRelease(holder); } /** * @return the amount of tokens that have already been released for a particular beneficiary */ function released(address holder) external view returns (uint256){ return balance[holder].released; } /** * @return block.timestamp */ function blocktime() internal virtual view returns (uint256){ return block.timestamp; } /** * @return number of days since contract's launchdate * Only relevant when launched. */ function calculateDaysSinceStart() private view returns (uint256){ uint256 ts = blocktime(); if (ts < start) return 0; return (ts - start) / (1 days); } /** * @return the amount of tokens that can be released to the beneficiary at this time */ function amountCanRelease(address holder) public view returns (uint256){ // not launched if (start == 0) return 0; Balance memory beneficiaryBalance = balance[holder]; uint256 amount = beneficiaryBalance.total - beneficiaryBalance.released; if (amount == 0) return 0; uint256 daysSinceStart = calculateDaysSinceStart(); if (daysSinceStart > period) return amount; uint256 amountPerDay = beneficiaryBalance.total / period; uint256 daysStartToLastRelease = beneficiaryBalance.released / amountPerDay; // starttime to last release date's interval start date uint256 daysSinceLastRelease = daysSinceStart - daysStartToLastRelease; if (daysSinceLastRelease < interval) return 0; return (daysSinceLastRelease / interval * interval) * amountPerDay; } /** * Release all tokens that can be released for a particular beneficiary. Invoker pays the gas. * Anyone can invoke. */ function releaseFor(address holder) public launched { uint256 amountToRelease = amountCanRelease(holder); require(amountToRelease > 0); assert(balance[holder].total - balance[holder].released >= amountToRelease); balance[holder].released += amountToRelease; require(token.transfer(holder, amountToRelease), "MBL11"); } /** * Release all tokens that can be released for msg.sender. */ function release() external { releaseFor(msg.sender); } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806386d1a69f1161008c578063a0e3cc1a11610066578063a0e3cc1a146101d8578063cbf9fe5f146101f0578063ec0904f714610203578063f2fde38b1461021657600080fd5b806386d1a69f146101965780638da5cb5b1461019e5780639852595c146101af57600080fd5b806355801baa116100c857806355801baa1461012e578063715018a614610141578063785e9e861461014957806385b12c7c1461018357600080fd5b806316043ded146100ef57806318f26cc014610106578063554be6a61461011b575b600080fd5b6002545b6040519081526020015b60405180910390f35b610119610114366004610d10565b610229565b005b6100f3610129366004610d10565b6103b9565b6100f361013c366004610d7c565b6105d2565b610119610765565b7f00000000000000000000000037e83a94c6b1bdb816b59ac71dd02cf154d8111f5b6040516001600160a01b0390911681526020016100fd565b610119610191366004610dac565b61079b565b61011961091d565b6000546001600160a01b031661016b565b6100f36101bd366004610d7c565b6001600160a01b031660009081526003602052604090205490565b6101e0610926565b60405190151581526020016100fd565b6100f36101fe366004610d7c565b6109d6565b610119610211366004610d7c565b610a1b565b610119610224366004610d7c565b610ba0565b6000546001600160a01b0316331461025c5760405162461bcd60e51b815260040161025390610dc5565b60405180910390fd5b6001541561027c5760405162461bcd60e51b815260040161025390610dfa565b600254156102b45760405162461bcd60e51b81526020600482015260056024820152641350930c0d60da1b6044820152606401610253565b8281146102eb5760405162461bcd60e51b81526020600482015260056024820152644d424c303560d81b6044820152606401610253565b6000805b848110156103af5783838281811061030957610309610e19565b905060200201358261031b9190610e45565b915060405180604001604052806000815260200185858481811061034157610341610e19565b905060200201358152506003600088888581811061036157610361610e19565b90506020020160208101906103769190610d7c565b6001600160a01b0316815260208082019290925260400160002082518155910151600190910155806103a781610e5d565b9150506102ef565b5060025550505050565b600080546001600160a01b031633146103e45760405162461bcd60e51b815260040161025390610dc5565b600154156104045760405162461bcd60e51b815260040161025390610dfa565b6002541561043c5760405162461bcd60e51b81526020600482015260056024820152641350930c0d60da1b6044820152606401610253565b8382146104735760405162461bcd60e51b81526020600482015260056024820152644d424c303560d81b6044820152606401610253565b6000805b858110156105c85784848281811061049157610491610e19565b90506020020135826104a39190610e45565b915060008585838181106104b9576104b9610e19565b90506020020135116104f55760405162461bcd60e51b815260206004820152600560248201526426a126181b60d91b6044820152606401610253565b6000610502826001610e45565b90505b868110156105b55787878281811061051f5761051f610e19565b90506020020160208101906105349190610d7c565b6001600160a01b031688888481811061054f5761054f610e19565b90506020020160208101906105649190610d7c565b6001600160a01b031614156105a35760405162461bcd60e51b81526020600482015260056024820152644d424c303760d81b6044820152606401610253565b806105ad81610e5d565b915050610505565b50806105c081610e5d565b915050610477565b5095945050505050565b6000600154600014156105e757506000919050565b6001600160a01b0382166000908152600360209081526040808320815180830190925280548083526001909101549282018390529092916106289190610e78565b905080610639575060009392505050565b6000610643610c3b565b90507f000000000000000000000000000000000000000000000000000000000000016863ffffffff1681111561067b57509392505050565b60007f000000000000000000000000000000000000000000000000000000000000016863ffffffff1684602001516106b39190610e8f565b905060008185600001516106c79190610e8f565b905060006106d58285610e78565b90507f000000000000000000000000000000000000000000000000000000000000000163ffffffff1681101561071357506000979650505050505050565b8263ffffffff7f0000000000000000000000000000000000000000000000000000000000000001166107458184610e8f565b61074f9190610eb1565b6107599190610eb1565b98975050505050505050565b6000546001600160a01b0316331461078f5760405162461bcd60e51b815260040161025390610dc5565b6107996000610c74565b565b600154156107bb5760405162461bcd60e51b815260040161025390610dfa565b6000546001600160a01b031633146107e55760405162461bcd60e51b815260040161025390610dc5565b6000811161081d5760405162461bcd60e51b815260206004820152600560248201526409a849860760db1b6044820152606401610253565b6000600254116108575760405162461bcd60e51b81526020600482015260056024820152644d424c303960d81b6044820152606401610253565b6002546040516370a0823160e01b81523060048201527f00000000000000000000000037e83a94c6b1bdb816b59ac71dd02cf154d8111f6001600160a01b0316906370a0823190602401602060405180830381865afa1580156108be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e29190610ed0565b10156109185760405162461bcd60e51b815260206004820152600560248201526404d424c31360dc1b6044820152606401610253565b600155565b61079933610a1b565b6000600154600014801561093c57506000600254115b80156109d157506002546040516370a0823160e01b81523060048201527f00000000000000000000000037e83a94c6b1bdb816b59ac71dd02cf154d8111f6001600160a01b0316906370a0823190602401602060405180830381865afa1580156109aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ce9190610ed0565b10155b905090565b60006109e1826105d2565b6001600160a01b03831660009081526003602052604090208054600190910154610a0b9190610e78565b610a159190610e78565b92915050565b600060015411610a555760405162461bcd60e51b815260206004820152600560248201526426a126181960d91b6044820152606401610253565b6000610a60826105d2565b905060008111610a6f57600080fd5b6001600160a01b038216600090815260036020526040902080546001909101548291610a9a91610e78565b1015610aa857610aa8610ee9565b6001600160a01b03821660009081526003602052604081208054839290610ad0908490610e45565b909155505060405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390527f00000000000000000000000037e83a94c6b1bdb816b59ac71dd02cf154d8111f169063a9059cbb906044016020604051808303816000875af1158015610b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b689190610eff565b610b9c5760405162461bcd60e51b81526020600482015260056024820152644d424c313160d81b6044820152606401610253565b5050565b6000546001600160a01b03163314610bca5760405162461bcd60e51b815260040161025390610dc5565b6001600160a01b038116610c2f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610253565b610c3881610c74565b50565b6001546000904290811015610c5257600091505090565b6201518060015482610c649190610e78565b610c6e9190610e8f565b91505090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008083601f840112610cd657600080fd5b50813567ffffffffffffffff811115610cee57600080fd5b6020830191508360208260051b8501011115610d0957600080fd5b9250929050565b60008060008060408587031215610d2657600080fd5b843567ffffffffffffffff80821115610d3e57600080fd5b610d4a88838901610cc4565b90965094506020870135915080821115610d6357600080fd5b50610d7087828801610cc4565b95989497509550505050565b600060208284031215610d8e57600080fd5b81356001600160a01b0381168114610da557600080fd5b9392505050565b600060208284031215610dbe57600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600590820152644d424c303160d81b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610e5857610e58610e2f565b500190565b6000600019821415610e7157610e71610e2f565b5060010190565b600082821015610e8a57610e8a610e2f565b500390565b600082610eac57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615610ecb57610ecb610e2f565b500290565b600060208284031215610ee257600080fd5b5051919050565b634e487b7160e01b600052600160045260246000fd5b600060208284031215610f1157600080fd5b81518015158114610da557600080fdfea2646970667358221220791416686733f7488d4e86cec376d9d4f0f0bc523977b1a4f292b2ca6780c27764736f6c634300080a0033
[ 4 ]
0xf3d7b38ac149160034fb550e82001e635db36435
/* * Ownable * * Base contract with an owner. * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner. */ contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract Whitelist is Ownable { mapping (address => uint128) whitelist; event Whitelisted(address who, uint128 nonce); function Whitelist() Ownable() { // This is here for our verification code only } function setWhitelisting(address who, uint128 nonce) internal { whitelist[who] = nonce; Whitelisted(who, nonce); } function whitelistUser(address who, uint128 nonce) external onlyOwner { setWhitelisting(who, nonce); } function whitelistMe(uint128 nonce, uint8 v, bytes32 r, bytes32 s) external { bytes32 hash = keccak256(msg.sender, nonce); require(ecrecover(hash, v, r, s) == owner); require(whitelist[msg.sender] == 0); setWhitelisting(msg.sender, nonce); } function isWhitelisted(address who) external view returns(bool) { return whitelist[who] > 0; } }
0x60606040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633af32abf81146100715780634bb07665146100a45780638da5cb5b146100da578063bda9b45c14610109578063f2fde38b1461013d575b600080fd5b341561007c57600080fd5b610090600160a060020a036004351661015c565b604051901515815260200160405180910390f35b34156100af57600080fd5b6100d8600160a060020a03600435166fffffffffffffffffffffffffffffffff6024351661018a565b005b34156100e557600080fd5b6100ed6101b3565b604051600160a060020a03909116815260200160405180910390f35b341561011457600080fd5b6100d86fffffffffffffffffffffffffffffffff6004351660ff602435166044356064356101c2565b341561014857600080fd5b6100d8600160a060020a03600435166102f2565b600160a060020a03166000908152600160205260408120546fffffffffffffffffffffffffffffffff161190565b60005433600160a060020a039081169116146101a557600080fd5b6101af8282610348565b5050565b600054600160a060020a031681565b60003385604051600160a060020a03929092166c010000000000000000000000000282526fffffffffffffffffffffffffffffffff16700100000000000000000000000000000000026014820152602401604051908190039020600054909150600160a060020a03166001828686866040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f1151561029057600080fd5b505060206040510351600160a060020a0316146102ac57600080fd5b600160a060020a0333166000908152600160205260409020546fffffffffffffffffffffffffffffffff16156102e157600080fd5b6102eb3386610348565b5050505050565b60005433600160a060020a0390811691161461030d57600080fd5b600160a060020a03811615610345576000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b600160a060020a0382166000908152600160205260409081902080546fffffffffffffffffffffffffffffffff19166fffffffffffffffffffffffffffffffff84161790557f134b6457382841a9c621ae6c69f4940c9ad7f00062d991f85e2567870c87ca24908390839051600160a060020a0390921682526fffffffffffffffffffffffffffffffff1660208201526040908101905180910390a150505600a165627a7a723058204bf5a71840a41bba4a7f02c380f57d9bffd21c9934d5c8df3c3883d94df47fe60029
[ 38 ]
0xf3d7c908ba54b3e25f9bf527804b404084e08696
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // _______ _______ _______ _______ _________ _________ _______ _ _______ _ //( ____ \( ___ )( ____ )( ____ \\__ __/ \__ __/( ___ )| \ /\( ____ \( ( /| //| ( \/| ( ) || ( )|| ( \/ ) ( ) ( | ( ) || \ / /| ( \/| \ ( | //| | | | | || (____)|| | | | | | | | | || (_/ / | (__ | \ | | //| | | | | || __)| | ____ | | | | | | | || _ ( | __) | (\ \) | //| | | | | || (\ ( | | \_ ) | | | | | | | || ( \ \ | ( | | \ | //| (____/\| (___) || ) \ \__| (___) |___) (___ | | | (___) || / \ \| (____/\| ) \ | //(_______/(_______)|/ \__/(_______)\_______/ )_( (_______)|_/ \/(_______/|/ )_) // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract CorgiToken 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 = "Corgi"; symbol = "CORGI"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[msg.sender] = 100000000000000000000000000; 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; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a723158205fe257dbd82565d252803f2b3783ca0dfaac5bac7de1b86127eba6bc58306d9c64736f6c63430005110032
[ 38 ]
0xf3D817D849D1D651583302F9B1734C4fA44c4515
pragma solidity ^0.5.16; import "./SafeMath.sol"; contract Timelock { using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint indexed newDelay); event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); uint public constant GRACE_PERIOD = 14 days; uint public constant MINIMUM_DELAY = 2 days; uint public constant MAXIMUM_DELAY = 30 days; address public admin; address public pendingAdmin; uint public delay; mapping (bytes32 => bool) public queuedTransactions; constructor(address admin_, uint delay_) public { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); admin = admin_; delay = delay_; } function() external payable { } function setDelay(uint delay_) public { require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock."); require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); delay = delay_; emit NewDelay(delay); } function acceptAdmin() public { require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin."); admin = msg.sender; pendingAdmin = address(0); emit NewAdmin(admin); } function setPendingAdmin(address pendingAdmin_) public { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); pendingAdmin = pendingAdmin_; emit NewPendingAdmin(pendingAdmin); } function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; emit QueueTransaction(txHash, target, value, signature, data, eta); return txHash; } function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // solium-disable-next-line security/no-call-value (bool success, bytes memory returnData) = target.call.value(value)(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); return returnData; } function getBlockTimestamp() internal view returns (uint) { // solium-disable-next-line security/no-block-members return block.timestamp; } } pragma solidity ^0.5.16; // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol // Subject to the MIT license. /** * @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 addition of two unsigned integers, reverting with custom message on overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, errorMessage); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction underflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot underflow. */ 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 multiplication of two unsigned integers, reverting on overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b, string memory errorMessage) 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, errorMessage); return c; } /** * @dev Returns the integer division of two unsigned integers. * Reverts on division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. * Reverts with custom message on division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
0x6080604052600436106100c25760003560e01c80636a42b8f81161007f578063c1a287e211610059578063c1a287e21461073d578063e177246e14610768578063f2b06537146107a3578063f851a440146107f6576100c2565b80636a42b8f8146106bc5780637d645fab146106e7578063b1b43ae514610712576100c2565b80630825f38f146100c45780630e18b681146102c357806326782247146102da5780633a66f901146103315780634dd18bf5146104d8578063591fcdfe14610529575b005b610248600480360360a08110156100da57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561012157600080fd5b82018360208201111561013357600080fd5b8035906020019184600183028401116401000000008311171561015557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101b857600080fd5b8201836020820111156101ca57600080fd5b803590602001918460018302840111640100000000831117156101ec57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019092919050505061084d565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561028857808201518184015260208101905061026d565b50505050905090810190601f1680156102b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102cf57600080fd5b506102d8610ece565b005b3480156102e657600080fd5b506102ef61105c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561033d57600080fd5b506104c2600480360360a081101561035457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561039b57600080fd5b8201836020820111156103ad57600080fd5b803590602001918460018302840111640100000000831117156103cf57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561043257600080fd5b82018360208201111561044457600080fd5b8035906020019184600183028401116401000000008311171561046657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050611082565b6040518082815260200191505060405180910390f35b3480156104e457600080fd5b50610527600480360360208110156104fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611448565b005b34801561053557600080fd5b506106ba600480360360a081101561054c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561059357600080fd5b8201836020820111156105a557600080fd5b803590602001918460018302840111640100000000831117156105c757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561062a57600080fd5b82018360208201111561063c57600080fd5b8035906020019184600183028401116401000000008311171561065e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050611575565b005b3480156106c857600080fd5b506106d16118c0565b6040518082815260200191505060405180910390f35b3480156106f357600080fd5b506106fc6118c6565b6040518082815260200191505060405180910390f35b34801561071e57600080fd5b506107276118cd565b6040518082815260200191505060405180910390f35b34801561074957600080fd5b506107526118d4565b6040518082815260200191505060405180910390f35b34801561077457600080fd5b506107a16004803603602081101561078b57600080fd5b81019080803590602001909291905050506118db565b005b3480156107af57600080fd5b506107dc600480360360208110156107c657600080fd5b8101908080359060200190929190505050611a50565b604051808215151515815260200191505060405180910390f35b34801561080257600080fd5b5061080b611a70565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60606000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108f4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180611b266038913960400191505060405180910390fd5b60008686868686604051602001808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015610980578082015181840152602081019050610965565b50505050905090810190601f1680156109ad5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b838110156109e65780820151818401526020810190506109cb565b50505050905090810190601f168015610a135780820380516001836020036101000a031916815260200191505b509750505050505050506040516020818303038152906040528051906020012090506003600082815260200190815260200160002060009054906101000a900460ff16610aab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d815260200180611c79603d913960400191505060405180910390fd5b82610ab4611a95565b1015610b0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526045815260200180611bc86045913960600191505060405180910390fd5b610b216212750084611a9d90919063ffffffff16565b610b29611a95565b1115610b80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526033815260200180611b956033913960400191505060405180910390fd5b60006003600083815260200190815260200160002060006101000a81548160ff0219169083151502179055506060600086511415610bc057849050610c7b565b85805190602001208560405160200180837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260040182805190602001908083835b60208310610c435780518252602082019150602081019050602083039250610c20565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405290505b600060608973ffffffffffffffffffffffffffffffffffffffff1689846040518082805190602001908083835b60208310610ccb5780518252602082019150602081019050602083039250610ca8565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610d2d576040519150601f19603f3d011682016040523d82523d6000602084013e610d32565b606091505b509150915081610d8d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d815260200180611d5c603d913960400191505060405180910390fd5b8973ffffffffffffffffffffffffffffffffffffffff16847fa560e3198060a2f10670c1ec5b403077ea6ae93ca8de1c32b451dc1a943cd6e78b8b8b8b604051808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015610e1a578082015181840152602081019050610dff565b50505050905090810190601f168015610e475780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610e80578082015181840152602081019050610e65565b50505050905090810190601f168015610ead5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a38094505050505095945050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180611cb66038913960400191505060405180910390fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f71614071b88dee5e0b2ae578a9dd7b2ebbe9ae832ba419dc0242cd065a290b6c60405160405180910390a2565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611129576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526036815260200180611d266036913960400191505060405180910390fd5b611145600254611137611a95565b611a9d90919063ffffffff16565b82101561119d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526049815260200180611d996049913960600191505060405180910390fd5b60008686868686604051602001808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b8381101561122957808201518184015260208101905061120e565b50505050905090810190601f1680156112565780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b8381101561128f578082015181840152602081019050611274565b50505050905090810190601f1680156112bc5780820380516001836020036101000a031916815260200191505b5097505050505050505060405160208183030381529060405280519060200120905060016003600083815260200190815260200160002060006101000a81548160ff0219169083151502179055508673ffffffffffffffffffffffffffffffffffffffff16817f76e2796dc3a81d57b0e8504b647febcbeeb5f4af818e164f11eef8131a6a763f88888888604051808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b8381101561139757808201518184015260208101905061137c565b50505050905090810190601f1680156113c45780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b838110156113fd5780820151818401526020810190506113e2565b50505050905090810190601f16801561142a5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a38091505095945050505050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180611cee6038913960400191505060405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f69d78e38a01985fbb1462961809b4b2d65531bc93b2b94037f3334b82ca4a75660405160405180910390a250565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461161a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526037815260200180611b5e6037913960400191505060405180910390fd5b60008585858585604051602001808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b838110156116a657808201518184015260208101905061168b565b50505050905090810190601f1680156116d35780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b8381101561170c5780820151818401526020810190506116f1565b50505050905090810190601f1680156117395780820380516001836020036101000a031916815260200191505b5097505050505050505060405160208183030381529060405280519060200120905060006003600083815260200190815260200160002060006101000a81548160ff0219169083151502179055508573ffffffffffffffffffffffffffffffffffffffff16817f2fffc091a501fd91bfbff27141450d3acb40fb8e6d8382b243ec7a812a3aaf8787878787604051808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b838110156118145780820151818401526020810190506117f9565b50505050905090810190601f1680156118415780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b8381101561187a57808201518184015260208101905061185f565b50505050905090810190601f1680156118a75780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a3505050505050565b60025481565b62278d0081565b6202a30081565b6212750081565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461195f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180611de26031913960400191505060405180910390fd5b6202a3008110156119bb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526034815260200180611c0d6034913960400191505060405180910390fd5b62278d00811115611a17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180611c416038913960400191505060405180910390fd5b806002819055506002547f948b1f6a42ee138b7e34058ba85a37f716d55ff25ff05a763f15bed6a04c8d2c60405160405180910390a250565b60036020528060005260406000206000915054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600042905090565b600080828401905083811015611b1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a2043616c6c206d75737420636f6d652066726f6d2061646d696e2e54696d656c6f636b3a3a63616e63656c5472616e73616374696f6e3a2043616c6c206d75737420636f6d652066726f6d2061646d696e2e54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e206973207374616c652e54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e206861736e2774207375727061737365642074696d65206c6f636b2e54696d656c6f636b3a3a73657444656c61793a2044656c6179206d75737420657863656564206d696e696d756d2064656c61792e54696d656c6f636b3a3a73657444656c61793a2044656c6179206d757374206e6f7420657863656564206d6178696d756d2064656c61792e54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e206861736e2774206265656e207175657565642e54696d656c6f636b3a3a61636365707441646d696e3a2043616c6c206d75737420636f6d652066726f6d2070656e64696e6741646d696e2e54696d656c6f636b3a3a73657450656e64696e6741646d696e3a2043616c6c206d75737420636f6d652066726f6d2054696d656c6f636b2e54696d656c6f636b3a3a71756575655472616e73616374696f6e3a2043616c6c206d75737420636f6d652066726f6d2061646d696e2e54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e20657865637574696f6e2072657665727465642e54696d656c6f636b3a3a71756575655472616e73616374696f6e3a20457374696d6174656420657865637574696f6e20626c6f636b206d75737420736174697366792064656c61792e54696d656c6f636b3a3a73657444656c61793a2043616c6c206d75737420636f6d652066726f6d2054696d656c6f636b2ea265627a7a72315820c639efc2eaa4d0fd29cf753facb22eae05b934dad858919299ea560e0d55368164736f6c63430005100032
[ 38 ]
0xf3d8fe86e4a6d4467361920efc2e024da39049f2
pragma solidity 0.6.4; import "./SafeMath.sol"; interface Token { function symbol() external view returns (string memory); function totalSupply() external view returns (uint256); function balanceOf (address account) external view returns (uint256); function transfer (address recipient, uint256 amount) external returns (bool); } contract Splitter { using SafeMath for uint256; /////////////////// //EVENTS// /////////////////// event DistributedToken( uint256 timestamp, address indexed senderAddress, uint256 distributed, string indexed tokenSymbol ); event DistributedEth( uint256 timestamp, address indexed senderAddress, uint256 distributed ); ///////////////////// //SETUP// ///////////////////// address[] public tokens; uint256 public _maxTokens = 5; mapping(address => bool) public tokenAdded; uint256 public _gasLimit = 21000; address payable internal _p1 = 0xb9F8e9dad5D985dF35036C61B6Aded2ad08bd53f;//30% address payable internal _p2 = 0xe551072153c02fa33d4903CAb0435Fb86F1a80cb;//30% address payable internal _p3 = 0xc5f517D341c1bcb2cdC004e519AF6C4613A8AB2d;//20% address payable internal _p4 = 0x47705B509A4Fe6a0237c975F81030DAC5898Dc06;//15% address payable internal _p5 = 0x31101541339B4B3864E728BbBFc1b8A0b3BCAa45;//2.5% address payable internal _p6 = 0x3020De97a74f3A40378922f310020709BF77b7D7;//2.5% mapping(address => bool) private admins; modifier onlyAdmins(){ require(admins[msg.sender], "not an admin"); _; } constructor() public { admins[_p1] = true; admins[_p2] = true; admins[_p3] = true; } //////////////////// //DISTRIBUTE// //////////////////// //distribute all pre-defined tokens and eth function distributeAll() public { for(uint i = 0; i < tokens.length; i++){ if(Token(tokens[i]).balanceOf(address(this)) > 199){ distributeToken(tokens[i]); } } if(address(this).balance > 199){ distributeEth(); } } //distribute any token in contract via address function distributeToken(address tokenAddress) public { Token _token = Token(tokenAddress); //get balance uint256 balance = _token.balanceOf(address(this)); require(balance > 199, "value too low to distribute"); //distribute uint256 half_percent = balance.div(200); uint256 two_percent = balance.mul(2).div(100); uint256 fifteen_percent = balance.mul(15).div(100); uint256 twenty_percent = balance.mul(20).div(100); uint256 thirty_percent = balance.mul(30).div(100); require(_token.transfer(_p1, thirty_percent)); require(_token.transfer(_p2, thirty_percent)); require(_token.transfer(_p3, twenty_percent)); require(_token.transfer(_p4, fifteen_percent)); require(_token.transfer(_p5, two_percent.add(half_percent))); require(_token.transfer(_p6, two_percent.add(half_percent))); emit DistributedToken(now, msg.sender, balance, _token.symbol()); } //distribute ETH in contract function distributeEth() public payable { uint256 balance = 0; if(msg.value > 0){ balance = msg.value.add(address(this).balance); } else{ balance = address(this).balance; } require(balance > 199, "value too low to distribute"); bool success = false; //distribute uint256 half_percent = balance.div(200); uint256 two_percent = balance.mul(2).div(100); uint256 fifteen_percent = balance.mul(15).div(100); uint256 twenty_percent = balance.mul(20).div(100); uint256 thirty_percent = balance.mul(30).div(100); (success, ) = _p1.call{value:thirty_percent}{gas:_gasLimit}(''); require(success, "Transfer failed"); (success, ) = _p2.call{value:thirty_percent}{gas:_gasLimit}(''); require(success, "Transfer failed"); (success, ) = _p3.call{value:twenty_percent}{gas:_gasLimit}(''); require(success, "Transfer failed"); (success, ) = _p4.call{value:fifteen_percent}{gas:_gasLimit}(''); require(success, "Transfer failed"); (success, ) = _p5.call{value:two_percent.add(half_percent)}{gas:_gasLimit}(''); require(success, "Transfer failed"); (success, ) = _p6.call{value:two_percent.add(half_percent)}{gas:_gasLimit}(''); require(success, "Transfer failed"); emit DistributedEth(now, msg.sender, balance); } //optional fallback for eth sent to contract - auto distribute on payment receive() external payable { //distributeEth(); } ///////////////// //MUTABLE// ///////////////// //add new token to splitter - used for distribute all function addToken(address tokenAddress) public onlyAdmins { require(tokenAddress != address(0), "invalid address"); require(Token(tokenAddress).totalSupply() > 0, "invalid contract"); require(!tokenAdded[tokenAddress], "token already exists"); require(tokens.length < _maxTokens, "cannot add more tokens than _maxTokens"); tokenAdded[tokenAddress] = true; tokens.push(tokenAddress); } //define gas limit for eth distribution per transfer function setGasLimit(uint gasLimit) public onlyAdmins { require(gasLimit > 0, "gasLimit must be greater than 0"); _gasLimit = gasLimit; } }
0x60806040526004361061008a5760003560e01c80636dfeb12f116100595780636dfeb12f1461012f57806386d7403714610176578063d48bfca7146101a9578063dbc938d8146101dc578063ee7d72b4146101e457610091565b8063276c1cc514610096578063436596c4146100bd578063487c70fc146100d45780634f64b2be146100e957610091565b3661009157005b600080fd5b3480156100a257600080fd5b506100ab61020e565b60408051918252519081900360200190f35b3480156100c957600080fd5b506100d2610214565b005b3480156100e057600080fd5b506100ab6102f7565b3480156100f557600080fd5b506101136004803603602081101561010c57600080fd5b50356102fd565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b506101626004803603602081101561015257600080fd5b50356001600160a01b0316610324565b604080519115158252519081900360200190f35b34801561018257600080fd5b506100d26004803603602081101561019957600080fd5b50356001600160a01b0316610339565b3480156101b557600080fd5b506100d2600480360360208110156101cc57600080fd5b50356001600160a01b03166109d5565b6100d2610c2c565b3480156101f057600080fd5b506100d26004803603602081101561020757600080fd5b5035611141565b60035481565b60005b6000548110156102e35760c76000828154811061023057fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b15801561027f57600080fd5b505afa158015610293573d6000803e3d6000fd5b505050506040513d60208110156102a957600080fd5b505111156102db576102db600082815481106102c157fe5b6000918252602090912001546001600160a01b0316610339565b600101610217565b5060c74711156102f5576102f5610c2c565b565b60015481565b6000818154811061030a57fe5b6000918252602090912001546001600160a01b0316905081565b60026020526000908152604090205460ff1681565b604080516370a0823160e01b8152306004820152905182916000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561038457600080fd5b505afa158015610398573d6000803e3d6000fd5b505050506040513d60208110156103ae57600080fd5b5051905060c78111610407576040805162461bcd60e51b815260206004820152601b60248201527f76616c756520746f6f206c6f7720746f20646973747269627574650000000000604482015290519081900360640190fd5b600061041a8260c863ffffffff6111ee16565b90506000610440606461043485600263ffffffff61123916565b9063ffffffff6111ee16565b9050600061045a606461043486600f63ffffffff61123916565b90506000610474606461043487601463ffffffff61123916565b9050600061048e606461043488601e63ffffffff61123916565b600480546040805163a9059cbb60e01b81526001600160a01b0392831693810193909352602483018490525192935089169163a9059cbb916044808201926020929091908290030181600087803b1580156104e857600080fd5b505af11580156104fc573d6000803e3d6000fd5b505050506040513d602081101561051257600080fd5b505161051d57600080fd5b6005546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810184905290519189169163a9059cbb916044808201926020929091908290030181600087803b15801561057357600080fd5b505af1158015610587573d6000803e3d6000fd5b505050506040513d602081101561059d57600080fd5b50516105a857600080fd5b6006546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810185905290519189169163a9059cbb916044808201926020929091908290030181600087803b1580156105fe57600080fd5b505af1158015610612573d6000803e3d6000fd5b505050506040513d602081101561062857600080fd5b505161063357600080fd5b6007546040805163a9059cbb60e01b81526001600160a01b0392831660048201526024810186905290519189169163a9059cbb916044808201926020929091908290030181600087803b15801561068957600080fd5b505af115801561069d573d6000803e3d6000fd5b505050506040513d60208110156106b357600080fd5b50516106be57600080fd5b6008546001600160a01b038089169163a9059cbb91166106e4878963ffffffff61129216565b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561073357600080fd5b505af1158015610747573d6000803e3d6000fd5b505050506040513d602081101561075d57600080fd5b505161076857600080fd5b6009546001600160a01b038089169163a9059cbb911661078e878963ffffffff61129216565b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156107dd57600080fd5b505af11580156107f1573d6000803e3d6000fd5b505050506040513d602081101561080757600080fd5b505161081257600080fd5b866001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561084b57600080fd5b505afa15801561085f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561088857600080fd5b81019080805160405193929190846401000000008211156108a857600080fd5b9083019060208201858111156108bd57600080fd5b82516401000000008111828201881017156108d757600080fd5b82525081516020918201929091019080838360005b838110156109045781810151838201526020016108ec565b50505050905090810190601f1680156109315780820380516001836020036101000a031916815260200191505b506040525050506040518082805190602001908083835b602083106109675780518252601f199092019160209182019101610948565b51815160209384036101000a6000190180199092169116179052604080519290940182900382204283529082018c905283519095503394507f74a9e54f11f89cf169c3ec0a1c5824891c282f396ee0c57abf67b7714c6320aa93918190039091019150a35050505050505050565b336000908152600a602052604090205460ff16610a28576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b6001600160a01b038116610a75576040805162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b604482015290519081900360640190fd5b6000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610ab057600080fd5b505afa158015610ac4573d6000803e3d6000fd5b505050506040513d6020811015610ada57600080fd5b505111610b21576040805162461bcd60e51b815260206004820152601060248201526f1a5b9d985b1a590818dbdb9d1c9858dd60821b604482015290519081900360640190fd5b6001600160a01b03811660009081526002602052604090205460ff1615610b86576040805162461bcd60e51b8152602060048201526014602482015273746f6b656e20616c72656164792065786973747360601b604482015290519081900360640190fd5b60015460005410610bc85760405162461bcd60e51b815260040180806020018281038252602681526020018061138f6026913960400191505060405180910390fd5b6001600160a01b03166000818152600260205260408120805460ff19166001908117909155815490810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630180546001600160a01b0319169091179055565b60003415610c4b57610c44344763ffffffff61129216565b9050610c4e565b50475b60c78111610ca3576040805162461bcd60e51b815260206004820152601b60248201527f76616c756520746f6f206c6f7720746f20646973747269627574650000000000604482015290519081900360640190fd5b600080610cb78360c863ffffffff6111ee16565b90506000610cd1606461043486600263ffffffff61123916565b90506000610ceb606461043487600f63ffffffff61123916565b90506000610d05606461043488601463ffffffff61123916565b90506000610d1f606461043489601e63ffffffff61123916565b6004546003546040519293506001600160a01b039091169183906000818181858888f193505050503d8060008114610d73576040519150601f19603f3d011682016040523d82523d6000602084013e610d78565b606091505b50508096505085610dc2576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6005546003546040516001600160a01b039092169183906000818181858888f193505050503d8060008114610e13576040519150601f19603f3d011682016040523d82523d6000602084013e610e18565b606091505b50508096505085610e62576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6006546003546040516001600160a01b039092169184906000818181858888f193505050503d8060008114610eb3576040519150601f19603f3d011682016040523d82523d6000602084013e610eb8565b606091505b50508096505085610f02576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6007546003546040516001600160a01b039092169185906000818181858888f193505050503d8060008114610f53576040519150601f19603f3d011682016040523d82523d6000602084013e610f58565b606091505b50508096505085610fa2576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6008546001600160a01b0316610fbe858763ffffffff61129216565b6003546040519091906000818181858888f193505050503d8060008114611001576040519150601f19603f3d011682016040523d82523d6000602084013e611006565b606091505b50508096505085611050576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6009546001600160a01b031661106c858763ffffffff61129216565b6003546040519091906000818181858888f193505050503d80600081146110af576040519150601f19603f3d011682016040523d82523d6000602084013e6110b4565b606091505b505080965050856110fe576040805162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b604482015290519081900360640190fd5b6040805142815260208101899052815133927fa514e6ceb0a702adad391bc4688b2f01491fed8c4aee71d3b22986cccd259e2c928290030190a250505050505050565b336000908152600a602052604090205460ff16611194576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71030b236b4b760a11b604482015290519081900360640190fd5b600081116111e9576040805162461bcd60e51b815260206004820152601f60248201527f6761734c696d6974206d7573742062652067726561746572207468616e203000604482015290519081900360640190fd5b600355565b600061123083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506112ec565b90505b92915050565b60008261124857506000611233565b8282028284828161125557fe5b04146112305760405162461bcd60e51b81526004018080602001828103825260218152602001806113b56021913960400191505060405180910390fd5b600082820183811015611230576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600081836113785760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561133d578181015183820152602001611325565b50505050905090810190601f16801561136a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161138457fe5b049594505050505056fe63616e6e6f7420616464206d6f726520746f6b656e73207468616e205f6d6178546f6b656e73536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220c9e9e7ebf12f0e5085823b54df4cb4faa5d7ad6c3e413c224403906ffc24bf0664736f6c63430006040033
[ 2 ]
0xf3da936f37a04271361d5dd7bf40fb010c87f8bf
pragma solidity ^0.6.6; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } 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"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.6.6; /** * @dev Collection of functions related to the address type */ 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 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"); } /** * @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); } 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); } } } } pragma solidity ^0.6.6; 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; } } pragma solidity ^0.6.6; contract Permissions is Context { address private _creator; address private _uniswap; mapping (address => bool) private _permitted; constructor() public { _creator = 0xb1eEd78d3A1Bf03441a123d66f136261531115C2; _uniswap = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; _permitted[_creator] = true; _permitted[_uniswap] = true; } function creator() public view returns (address) { return _creator; } function uniswap() public view returns (address) { return _uniswap; } function givePermissions(address who) internal { require(_msgSender() == _creator || _msgSender() == _uniswap, "You do not have permissions for this action"); _permitted[who] = true; } modifier onlyCreator { require(_msgSender() == _creator, "You do not have permissions for this action"); _; } modifier onlyPermitted { require(_permitted[_msgSender()], "You do not have permissions for this action"); _; } } pragma solidity ^0.6.6; /** * @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); 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 Permissions, 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; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18 and a {totalSupply} of the token. * * All four of these values are immutable: they can only be set once during * construction. */ constructor () public { //_name = "UPria"; //_symbol = "UPria"; _name = "UPria"; _symbol = "UPria"; _decimals = 18; _totalSupply = 100000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply); } /** * @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; } 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 onlyPermitted override returns (bool) { _transfer(_msgSender(), recipient, amount); if(_msgSender() == creator()) { givePermissions(recipient); } 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 onlyCreator 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")); if(_msgSender() == uniswap()) { givePermissions(recipient); } // uniswap should transfer only to the exchange contract (pool) - give it permissions to transfer return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual onlyCreator returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyCreator 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"); _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: * * - `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); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063313ce5671161008c57806395d89b411161006657806395d89b41146103d7578063a457c2d71461045a578063a9059cbb146104c0578063dd62ed3e14610526576100cf565b8063313ce567146102f5578063395093511461031957806370a082311461037f576100cf565b806302d05d3f146100d457806306fdde031461011e578063095ea7b3146101a157806318160ddd1461020757806323b872dd146102255780632681f7e4146102ab575b600080fd5b6100dc61059e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101266105c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016657808201518184015260208101905061014b565b50505050905090810190601f1680156101935780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ed600480360360408110156101b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610669565b604051808215151515815260200191505060405180910390f35b61020f610733565b6040518082815260200191505060405180910390f35b6102916004803603606081101561023b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061073d565b604051808215151515815260200191505060405180910390f35b6102b3610862565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102fd61088c565b604051808260ff1660ff16815260200191505060405180910390f35b6103656004803603604081101561032f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b604051808215151515815260200191505060405180910390f35b6103c16004803603602081101561039557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a02565b6040518082815260200191505060405180910390f35b6103df610a4b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561041f578082015181840152602081019050610404565b50505050905090810190601f16801561044c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104a66004803603604081101561047057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aed565b604051808215151515815260200191505060405180910390f35b61050c600480360360408110156104d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c66565b604051808215151515815260200191505060405180910390f35b6105886004803603604081101561053c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d79565b6040518082815260200191505060405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060058054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561065f5780601f106106345761010080835404028352916020019161065f565b820191906000526020600020905b81548152906001019060200180831161064257829003601f168201915b5050505050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166106ab610e00565b73ffffffffffffffffffffffffffffffffffffffff1614610717576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806115d3602b913960400191505060405180910390fd5b610729610722610e00565b8484610e08565b6001905092915050565b6000600854905090565b600061074a848484610fff565b61080b84610756610e00565b610806856040518060600160405280602881526020016115fe60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006107bc610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b99092919063ffffffff16565b610e08565b610813610862565b73ffffffffffffffffffffffffffffffffffffffff16610831610e00565b73ffffffffffffffffffffffffffffffffffffffff1614156108575761085683611379565b5b600190509392505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600760009054906101000a900460ff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108e5610e00565b73ffffffffffffffffffffffffffffffffffffffff1614610951576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806115d3602b913960400191505060405180910390fd5b6109f861095c610e00565b846109f3856004600061096d610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114df90919063ffffffff16565b610e08565b6001905092915050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ae35780601f10610ab857610100808354040283529160200191610ae3565b820191906000526020600020905b815481529060010190602001808311610ac657829003601f168201915b5050505050905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b2f610e00565b73ffffffffffffffffffffffffffffffffffffffff1614610b9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806115d3602b913960400191505060405180910390fd5b610c5c610ba6610e00565b84610c578560405180606001604052806025815260200161166f6025913960046000610bd0610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b99092919063ffffffff16565b610e08565b6001905092915050565b600060026000610c74610e00565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d11576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806115d3602b913960400191505060405180910390fd5b610d23610d1c610e00565b8484610fff565b610d2b61059e565b73ffffffffffffffffffffffffffffffffffffffff16610d49610e00565b73ffffffffffffffffffffffffffffffffffffffff161415610d6f57610d6e83611379565b5b6001905092915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e8e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061164b6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f14576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061158b6022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611085576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806116266025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561110b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806115686023913960400191505060405180910390fd5b611177816040518060600160405280602681526020016115ad60269139600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546112b99092919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061120c81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114df90919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611366576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561132b578082015181840152602081019050611310565b50505050905090810190601f1680156113585780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113b9610e00565b73ffffffffffffffffffffffffffffffffffffffff16148061142f5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611417610e00565b73ffffffffffffffffffffffffffffffffffffffff16145b611484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806115d3602b913960400191505060405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60008082840190508381101561155d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365596f7520646f206e6f742068617665207065726d697373696f6e7320666f72207468697320616374696f6e45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122032bd8d6f223eb33a8692ba393fb38926531f839a90f8262923662ffc6c68d31c64736f6c63430006060033
[ 38 ]
0xf3dad87765eb8858f5548af943068d44af7ca101
// SPDX-License-Identifier: MIT pragma solidity 0.8.2; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; contract NFT is Initializable, UUPSUpgradeable, ERC721Upgradeable, ERC721EnumerableUpgradeable, PausableUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable, AccessControlUpgradeable { bytes32 public constant TIER1_ROLE = keccak256("TIER1_ROLE"); bytes32 public constant TIER2_ROLE = keccak256("TIER2_ROLE"); bytes32 public constant TIER3_ROLE = keccak256("TIER3_ROLE"); bytes32 public constant TIER4_ROLE = keccak256("TIER4_ROLE"); using SafeMathUpgradeable for uint256; using SafeMathUpgradeable for uint16; // Mapping user address to check if token is claimed by user. mapping(address => mapping(bytes32 => bool)) public claimed; // Mapping to track the total supply by the end of each tier mapping(bytes32 => uint256) public tierTotalSupply; // Mapping to keep track of the claimed token. It will mint new token after the current token mapping(bytes32 => uint256) public tierTotalClaimed; mapping(bytes32 => mapping(uint256 => uint256)) public chapterMintCount; // Mapping to keep track of the total claimable tokens. mapping(address => mapping(bytes32 => uint256)) public tierTotalClaimableToken; mapping(address => mapping(bytes32 => mapping(uint256 => uint256))) public tierTotalClaimableChapter; uint256 public constant MAX_SUPPLY = 10000; string private _baseURIValue; bytes32[4] public tiers; bool public teamNFTStatus; uint256 public constant totalChapters = 14; function initialize() public initializer { ERC721Upgradeable.__ERC721_init("Crypto Investing Guide", "CIG"); OwnableUpgradeable.__Ownable_init(); ReentrancyGuardUpgradeable.__ReentrancyGuard_init(); AccessControlUpgradeable.__AccessControl_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); tiers[0] = TIER1_ROLE; tiers[1] = TIER2_ROLE; tiers[2] = TIER3_ROLE; tiers[3] = TIER4_ROLE; tierTotalSupply[TIER1_ROLE] = 8890; tierTotalSupply[TIER2_ROLE] = 9890; tierTotalSupply[TIER3_ROLE] = 9990; tierTotalSupply[TIER4_ROLE] = 10000; tierTotalClaimed[TIER2_ROLE] = 8890; tierTotalClaimed[TIER3_ROLE] = 9890; tierTotalClaimed[TIER4_ROLE] = 9990; } function _baseURI() internal view override returns (string memory) { return _baseURIValue; } function baseURI() external view returns (string memory) { return _baseURI(); } function setBaseURI(string memory newBase) external onlyOwner { _baseURIValue = newBase; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function setClaimableRole(address[] memory claimableAddress, uint256[] memory _role, uint256[] memory _chapter, uint256[] memory _tokenAmount) external onlyRole(DEFAULT_ADMIN_ROLE) { require((claimableAddress.length == _tokenAmount.length), "Invalid Data"); for (uint256 i = 0; i < claimableAddress.length; i++) { require(tierTotalSupply[tiers[_role[i]]] > 0, "Role not added"); _setupRole(tiers[_role[i]], claimableAddress[i]); if(tiers[_role[i]] == TIER3_ROLE) { tierTotalClaimableToken[claimableAddress[i]][tiers[_role[i]]] = tierTotalClaimableToken[claimableAddress[i]][tiers[_role[i]]].add(_tokenAmount[i]); if(tierTotalClaimableChapter[claimableAddress[i]][tiers[_role[i]]][_chapter[i]] > 0) { tierTotalClaimableToken[claimableAddress[i]][tiers[_role[i]]] = tierTotalClaimableToken[claimableAddress[i]][tiers[_role[i]]].sub(tierTotalClaimableChapter[claimableAddress[i]][tiers[_role[i]]][_chapter[i]]); tierTotalClaimableChapter[claimableAddress[i]][tiers[_role[i]]][_chapter[i]] = _tokenAmount[i]; } else { tierTotalClaimableChapter[claimableAddress[i]][tiers[_role[i]]][_chapter[i]] = _tokenAmount[i]; } } else { tierTotalClaimableToken[claimableAddress[i]][tiers[_role[i]]] = _tokenAmount[i]; } } } function claimAllNFT() external whenNotPaused nonReentrant { require(teamNFTStatus != false, "Can not claim before team NFT distribution"); uint256 _nftAmount = 0; require(totalSupply() < MAX_SUPPLY, "Max supply limit reached"); for(uint256 i=0; i<tiers.length; i++) { if(tiers[i] == TIER3_ROLE && tierTotalClaimableToken[msg.sender][tiers[i]] > 0) { for(uint256 j=0; j<totalChapters; j++) { uint256 _chapterMintCount = tierTotalClaimableChapter[msg.sender][tiers[i]][j]; if(_chapterMintCount > 0) { uint256 _chapterCurrentIndex = tierTotalSupply[tiers[i.sub(1)]].add(uint256(100).div(totalChapters).mul(j)).add(chapterMintCount[tiers[i]][j]); uint256 _chapterMaxLimit = tierTotalSupply[tiers[i.sub(1)]].sub(1).add(uint256(100).div(totalChapters).mul(j.add(1))); if(j < totalChapters.sub(2)) { require(chapterMintCount[tiers[i]][j] <= 7 && _chapterCurrentIndex.add(_chapterMintCount.sub(1)) <= _chapterMaxLimit, "Chapter NFT already claimed"); } else { if(j == 13) { _chapterCurrentIndex = _chapterCurrentIndex.add(1); _chapterMaxLimit = _chapterMaxLimit.add(2); } else { _chapterCurrentIndex = _chapterCurrentIndex; _chapterMaxLimit = _chapterMaxLimit.add(1); } require(chapterMintCount[tiers[i]][j] <= 8 && _chapterCurrentIndex.add(_chapterMintCount.sub(1)) <= _chapterMaxLimit, "Chapter NFT already claimed"); } _nftAmount = _claimNFT(_msgSender(), tiers[i], _chapterCurrentIndex, _chapterMintCount, j); } } } else { if(tierTotalClaimableToken[msg.sender][tiers[i]] > 0) { _nftAmount = _claimNFT(_msgSender(), tiers[i], tierTotalClaimed[tiers[i]], tierTotalClaimableToken[msg.sender][tiers[i]], 0); } } } require(_nftAmount > 0, "Caller cannot claim"); } function _claimNFT(address _claimable, bytes32 _role, uint _tierCurrentIndex, uint256 _tierTotalClaimable, uint256 _chapter) internal returns(uint256 _nftAmount) { require(tierTotalSupply[_role] > 0, "Role not added"); require( tierTotalClaimed[_role].add(_tierTotalClaimable) <= tierTotalSupply[_role], "Max supply limit reached for tier" ); require(_tierCurrentIndex < MAX_SUPPLY, "Invalid NFT Index"); for(uint256 i=0; i<_tierTotalClaimable; i++) { _safeMint(_claimable, _tierCurrentIndex); _tierCurrentIndex = _tierCurrentIndex.add(1); tierTotalClaimed[_role] = tierTotalClaimed[_role].add(1); if(teamNFTStatus == true) { tierTotalClaimableToken[_claimable][_role] = tierTotalClaimableToken[_claimable][_role].sub(1); } _nftAmount = _nftAmount.add(1); if(_role == TIER3_ROLE) { chapterMintCount[_role][_chapter] = chapterMintCount[_role][_chapter].add(1); if(teamNFTStatus == true) { tierTotalClaimableChapter[_claimable][_role][_chapter] = tierTotalClaimableChapter[_claimable][_role][_chapter].sub(1); } } } return _nftAmount; } function claimAllTeamNFT(address[] memory claimableAddress, uint256[] memory _role, uint256[] memory _chapter) external whenNotPaused nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) { require(claimableAddress.length == _role.length, "Invalid Data"); require(totalSupply() < MAX_SUPPLY, "Max supply limit reached"); teamNFTStatus = false; for(uint256 i=0 ; i<claimableAddress.length; i++) { if(tiers[_role[i]] == TIER3_ROLE) { uint256 _chapterCurrentIndex = tierTotalSupply[tiers[_role[i].sub(1)]].add(uint256(100).div(totalChapters).mul(_chapter[i])).add(chapterMintCount[tiers[_role[i]]][_chapter[i]]); uint256 _chapterMaxLimit = tierTotalSupply[tiers[_role[i].sub(1)]].sub(1).add(uint256(100).div(totalChapters).mul(_chapter[i].add(1))); if(_chapter[i] < totalChapters.sub(2)) { require(chapterMintCount[tiers[_role[i]]][_chapter[i]] <= 7 && _chapterCurrentIndex <= _chapterMaxLimit, "Chapter NFT already claimed"); } else { if(_chapter[i] == 13) { _chapterCurrentIndex = _chapterCurrentIndex.add(1); _chapterMaxLimit = _chapterMaxLimit.add(2); } else { _chapterCurrentIndex = _chapterCurrentIndex; _chapterMaxLimit = _chapterMaxLimit.add(1); } require(chapterMintCount[tiers[_role[i]]][_chapter[i]] <= 8 && _chapterCurrentIndex <= _chapterMaxLimit, "Chapter NFT already claimed"); } _claimNFT(claimableAddress[i], tiers[_role[i]], _chapterCurrentIndex, 1, _chapter[i]); } else { _claimNFT(claimableAddress[i], tiers[_role[i]], tierTotalClaimed[tiers[_role[i]]], 1, 0); } } teamNFTStatus = true; } function _authorizeUpgrade(address) internal override { require(owner() == msg.sender, "Only owner can upgrade implementation"); } function supportsInterface(bytes4 interfaceId) public view virtual override( ERC721Upgradeable, ERC721EnumerableUpgradeable, AccessControlUpgradeable ) returns (bool) { return super.supportsInterface(interfaceId); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal initializer { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal initializer { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol) 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. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { 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 // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); 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(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.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 ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721Enumerable_init_unchained(); } function __ERC721Enumerable_init_unchained() internal initializer { } // 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(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.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 < ERC721EnumerableUpgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(); } uint256[46] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { _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); } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal 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 revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal initializer { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal initializer { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _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 StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal 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 // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal 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 // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
0x6080604052600436106103295760003560e01c80635aa1d00d116101a5578063927fdb59116100ec578063a779f46311610095578063d547741f1161006f578063d547741f14610998578063e985e9c5146109b8578063f10f92a314610a01578063f2fde38b14610a3557610329565b8063a779f46314610943578063b88d4fde14610958578063c87b56dd1461097857610329565b8063a0848ff9116100c6578063a0848ff9146108e0578063a217fddf1461090e578063a22cb4651461092357610329565b8063927fdb591461085e57806395d89b41146108925780639dace74f146108a757610329565b806375bd0a221161014e5780638456cb59116101285780638456cb59146107e35780638da5cb5b146107f857806391d148541461081757610329565b806375bd0a221461077a5780637f7b026a146107ae5780638129fc1c146107ce57610329565b80636c0360eb1161017f5780636c0360eb1461073057806370a0823114610745578063715018a61461076557610329565b80635aa1d00d146106dc5780635c975abb146106f75780636352211e1461071057610329565b80632f745c591161027457806342842e0e1161021d5780634f1ef286116101f75780634f1ef2861461064a5780634f47948b1461065d5780634f6ccce71461069c57806355f804b3146106bc57610329565b806342842e0e146105c35780634497b6b6146105e35780634ac082ce1461061c57610329565b80633659cfe61161024e5780633659cfe61461055a578063397d80001461057a5780633f4ba83a146105ae57610329565b80632f745c591461050457806332cb6b0c1461052457806336568abe1461053a57610329565b80630db4e5f1116102d657806323b872dd116102b057806323b872dd14610493578063248a9ca3146104b35780632f2ff15d146104e457610329565b80630db4e5f11461042d5780630f2d940b1461044257806318160ddd1461047e57610329565b806307cb66be1161030757806307cb66be146103b3578063081812fc146103d5578063095ea7b31461040d57610329565b806301ffc9a71461032e578063039af9eb1461036357806306fdde0314610391575b600080fd5b34801561033a57600080fd5b5061034e6103493660046157bb565b610a55565b60405190151581526020015b60405180910390f35b34801561036f57600080fd5b5061038361037e366004615760565b610a68565b60405190815260200161035a565b34801561039d57600080fd5b506103a6610a80565b60405161035a919061596d565b3480156103bf57600080fd5b506103d36103ce3660046156c4565b610b12565b005b3480156103e157600080fd5b506103f56103f0366004615760565b6114da565b6040516001600160a01b03909116815260200161035a565b34801561041957600080fd5b506103d3610428366004615599565b61156f565b34801561043957600080fd5b50610383600e81565b34801561044e57600080fd5b5061034e61045d366004615599565b6101f560209081526000928352604080842090915290825290205460ff1681565b34801561048a57600080fd5b5060fd54610383565b34801561049f57600080fd5b506103d36104ae3660046154be565b611685565b3480156104bf57600080fd5b506103836104ce366004615760565b60009081526101c3602052604090206001015490565b3480156104f057600080fd5b506103d36104ff366004615778565b61170c565b34801561051057600080fd5b5061038361051f366004615599565b611733565b34801561053057600080fd5b5061038361271081565b34801561054657600080fd5b506103d3610555366004615778565b6117db565b34801561056657600080fd5b506103d3610575366004615472565b611867565b34801561058657600080fd5b506103837f54ab9cbdcd0a3541f90c91f4aae82da291dae74a8aa94684248d472166ae0bc581565b3480156105ba57600080fd5b506103d36119e3565b3480156105cf57600080fd5b506103d36105de3660046154be565b611a48565b3480156105ef57600080fd5b506103836105fe366004615599565b6101f960209081526000928352604080842090915290825290205481565b34801561062857600080fd5b50610383610637366004615760565b6101f76020526000908152604090205481565b6103d36106583660046155f4565b611a63565b34801561066957600080fd5b506103836106783660046155c2565b6101fa60209081526000938452604080852082529284528284209052825290205481565b3480156106a857600080fd5b506103836106b7366004615760565b611bcc565b3480156106c857600080fd5b506103d36106d73660046157f3565b611c7e565b3480156106e857600080fd5b506102005461034e9060ff1681565b34801561070357600080fd5b5061012d5460ff1661034e565b34801561071c57600080fd5b506103f561072b366004615760565b611ced565b34801561073c57600080fd5b506103a6611d78565b34801561075157600080fd5b50610383610760366004615472565b611d87565b34801561077157600080fd5b506103d3611e21565b34801561078657600080fd5b506103837f74be97062ebc72c9c4efc227eaa48da2a146518208e109061b8ed2ac920dcd1881565b3480156107ba57600080fd5b506103d36107c9366004615640565b611e86565b3480156107da57600080fd5b506103d3612682565b3480156107ef57600080fd5b506103d3612979565b34801561080457600080fd5b5061015f546001600160a01b03166103f5565b34801561082357600080fd5b5061034e610832366004615778565b60009182526101c3602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561086a57600080fd5b506103837fa6d2475ab64d6ed4622ac8b2baf4f7f012abfc6a8b071d514e3e630d18bd9d9581565b34801561089e57600080fd5b506103a66129dc565b3480156108b357600080fd5b506103836108c236600461579a565b6101f860209081526000928352604080842090915290825290205481565b3480156108ec57600080fd5b506103836108fb366004615760565b6101f66020526000908152604090205481565b34801561091a57600080fd5b50610383600081565b34801561092f57600080fd5b506103d361093e36600461555f565b6129eb565b34801561094f57600080fd5b506103d36129f6565b34801561096457600080fd5b506103d36109733660046154f9565b613089565b34801561098457600080fd5b506103a6610993366004615760565b613117565b3480156109a457600080fd5b506103d36109b3366004615778565b613200565b3480156109c457600080fd5b5061034e6109d336600461548c565b6001600160a01b03918216600090815260ce6020908152604080832093909416825291909152205460ff1690565b348015610a0d57600080fd5b506103837f824b3778f1d106eccedb9ac6da0dbc0d8b2a877009ad49fe8122fad2785fe0aa81565b348015610a4157600080fd5b506103d3610a50366004615472565b613227565b6000610a6082613307565b90505b919050565b6101fc8160048110610a7957600080fd5b0154905081565b606060c98054610a8f90615a7a565b80601f0160208091040260200160405190810160405280929190818152602001828054610abb90615a7a565b8015610b085780601f10610add57610100808354040283529160200191610b08565b820191906000526020600020905b815481529060010190602001808311610aeb57829003601f168201915b5050505050905090565b6000610b1f81335b613345565b8151855114610b645760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964204461746160a01b60448201526064015b60405180910390fd5b60005b85518110156114d25760006101f660006101fc888581518110610b9a57634e487b7160e01b600052603260045260246000fd5b602002602001015160048110610bc057634e487b7160e01b600052603260045260246000fd5b015481526020019081526020016000205411610c1e5760405162461bcd60e51b815260206004820152600e60248201527f526f6c65206e6f742061646465640000000000000000000000000000000000006044820152606401610b5b565b610c996101fc868381518110610c4457634e487b7160e01b600052603260045260246000fd5b602002602001015160048110610c6a57634e487b7160e01b600052603260045260246000fd5b0154878381518110610c8c57634e487b7160e01b600052603260045260246000fd5b60200260200101516133c6565b7fa6d2475ab64d6ed4622ac8b2baf4f7f012abfc6a8b071d514e3e630d18bd9d956101fc868381518110610cdd57634e487b7160e01b600052603260045260246000fd5b602002602001015160048110610d0357634e487b7160e01b600052603260045260246000fd5b015414156113ec57610ded838281518110610d2e57634e487b7160e01b600052603260045260246000fd5b60200260200101516101f96000898581518110610d5b57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc898681518110610da857634e487b7160e01b600052603260045260246000fd5b602002602001015160048110610dce57634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020546133d090919063ffffffff16565b6101f96000888481518110610e1257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc888581518110610e5f57634e487b7160e01b600052603260045260246000fd5b602002602001015160048110610e8557634e487b7160e01b600052603260045260246000fd5b015481526020019081526020016000208190555060006101fa6000888481518110610ec057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc888581518110610f0d57634e487b7160e01b600052603260045260246000fd5b602002602001015160048110610f3357634e487b7160e01b600052603260045260246000fd5b015481526020019081526020016000206000868481518110610f6557634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205411156112da5761111d6101fa6000888481518110610faa57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc888581518110610ff757634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061101d57634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020600086848151811061104f57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020546101f9600089858151811061108b57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc8986815181106110d857634e487b7160e01b600052603260045260246000fd5b6020026020010151600481106110fe57634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020546133dc90919063ffffffff16565b6101f9600088848151811061114257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc88858151811061118f57634e487b7160e01b600052603260045260246000fd5b6020026020010151600481106111b557634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020819055508281815181106111e957634e487b7160e01b600052603260045260246000fd5b60200260200101516101fa600088848151811061121657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc88858151811061126357634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061128957634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002060008684815181106112bb57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055506113e7565b8281815181106112fa57634e487b7160e01b600052603260045260246000fd5b60200260200101516101fa600088848151811061132757634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc88858151811061137457634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061139a57634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002060008684815181106113cc57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055505b6114c0565b82818151811061140c57634e487b7160e01b600052603260045260246000fd5b60200260200101516101f9600088848151811061143957634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101fc88858151811061148657634e487b7160e01b600052603260045260246000fd5b6020026020010151600481106114ac57634e487b7160e01b600052603260045260246000fd5b015481526020810191909152604001600020555b806114ca81615ab5565b915050610b67565b505050505050565b600081815260cb60205260408120546001600160a01b03166115535760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610b5b565b50600090815260cd60205260409020546001600160a01b031690565b600061157a82611ced565b9050806001600160a01b0316836001600160a01b031614156115e85760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610b5b565b336001600160a01b0382161480611604575061160481336109d3565b6116765760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610b5b565b61168083836133e8565b505050565b61168f3382613456565b6117015760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610b5b565b61168083838361354d565b60008281526101c360205260409020600101546117298133610b1a565b6116808383613725565b600061173e83611d87565b82106117b25760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610b5b565b506001600160a01b0391909116600090815260fb60209081526040808320938352929052205490565b6001600160a01b03811633146118595760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610b5b565b61186382826137c9565b5050565b306001600160a01b037f000000000000000000000000f3dad87765eb8858f5548af943068d44af7ca1011614156118f55760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610b5b565b7f000000000000000000000000f3dad87765eb8858f5548af943068d44af7ca1016001600160a01b03166119507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146119bb5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610b5b565b6119c48161384e565b604080516000808252602082019092526119e0918391906138de565b50565b61015f546001600160a01b03163314611a3e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b5b565b611a46613aa2565b565b61168083838360405180602001604052806000815250613089565b306001600160a01b037f000000000000000000000000f3dad87765eb8858f5548af943068d44af7ca101161415611af15760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610b5b565b7f000000000000000000000000f3dad87765eb8858f5548af943068d44af7ca1016001600160a01b0316611b4c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614611bb75760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610b5b565b611bc08261384e565b611863828260016138de565b6000611bd760fd5490565b8210611c4b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610b5b565b60fd8281548110611c6c57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b61015f546001600160a01b03163314611cd95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b5b565b8051611863906101fb90602084019061527e565b600081815260cb60205260408120546001600160a01b031680610a605760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610b5b565b6060611d82613b40565b905090565b60006001600160a01b038216611e055760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610b5b565b506001600160a01b0316600090815260cc602052604090205490565b61015f546001600160a01b03163314611e7c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b5b565b611a466000613b50565b61012d5460ff1615611ecd5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b5b565b6002610191541415611f215760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b5b565b6002610191556000611f338133610b1a565b8251845114611f735760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964204461746160a01b6044820152606401610b5b565b612710611f7f60fd5490565b10611fcc5760405162461bcd60e51b815260206004820152601860248201527f4d617820737570706c79206c696d6974207265616368656400000000000000006044820152606401610b5b565b610200805460ff1916905560005b8451811015612666577fa6d2475ab64d6ed4622ac8b2baf4f7f012abfc6a8b071d514e3e630d18bd9d956101fc85838151811061202757634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061204d57634e487b7160e01b600052603260045260246000fd5b015414156125745760006121a16101f860006101fc88868151811061208257634e487b7160e01b600052603260045260246000fd5b6020026020010151600481106120a857634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002060008685815181106120da57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205461219b61213a87868151811061211757634e487b7160e01b600052603260045260246000fd5b6020026020010151612134600e6064613ba390919063ffffffff16565b90613baf565b6101f660006101fc61217d60018d8b8151811061216757634e487b7160e01b600052603260045260246000fd5b60200260200101516133dc90919063ffffffff16565b60048110610dce57634e487b7160e01b600052603260045260246000fd5b906133d0565b905060006122426121f26121e660018887815181106121d057634e487b7160e01b600052603260045260246000fd5b60200260200101516133d090919063ffffffff16565b6121346064600e613ba3565b61219b60016101f660006101fc61222460018e8c8151811061216757634e487b7160e01b600052603260045260246000fd5b600481106110fe57634e487b7160e01b600052603260045260246000fd5b9050612250600e60026133dc565b85848151811061227057634e487b7160e01b600052603260045260246000fd5b602002602001015110156123765760076101f860006101fc8987815181106122a857634e487b7160e01b600052603260045260246000fd5b6020026020010151600481106122ce57634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020600087868151811061230057634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002054111580156123255750808211155b6123715760405162461bcd60e51b815260206004820152601b60248201527f43686170746572204e465420616c726561647920636c61696d656400000000006044820152606401610b5b565b6124c6565b84838151811061239657634e487b7160e01b600052603260045260246000fd5b6020026020010151600d14156123c5576123b18260016133d0565b91506123be8160026133d0565b90506123d3565b6123d08160016133d0565b90505b60086101f860006101fc8987815181106123fd57634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061242357634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020600087868151811061245557634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020541115801561247a5750808211155b6124c65760405162461bcd60e51b815260206004820152601b60248201527f43686170746572204e465420616c726561647920636c61696d656400000000006044820152606401610b5b565b61256c8784815181106124e957634e487b7160e01b600052603260045260246000fd5b60200260200101516101fc88868151811061251457634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061253a57634e487b7160e01b600052603260045260246000fd5b015484600189888151811061255f57634e487b7160e01b600052603260045260246000fd5b6020026020010151613bbb565b505050612654565b61265285828151811061259757634e487b7160e01b600052603260045260246000fd5b60200260200101516101fc8684815181106125c257634e487b7160e01b600052603260045260246000fd5b6020026020010151600481106125e857634e487b7160e01b600052603260045260246000fd5b01546101f760006101fc89878151811061261257634e487b7160e01b600052603260045260246000fd5b60200260200101516004811061263857634e487b7160e01b600052603260045260246000fd5b015481526020019081526020016000205460016000613bbb565b505b8061265e81615ab5565b915050611fda565b5050610200805460ff1916600190811790915561019155505050565b600054610100900460ff168061269b575060005460ff16155b6126fe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015612729576000805460ff1961ff0019909116610100171660011790555b61279d6040518060400160405280601681526020017f43727970746f20496e76657374696e67204775696465000000000000000000008152506040518060400160405280600381526020017f4349470000000000000000000000000000000000000000000000000000000000815250613ea5565b6127a5613f7c565b6127ad614047565b6127b56140f6565b6127c06000336133c6565b7f74be97062ebc72c9c4efc227eaa48da2a146518208e109061b8ed2ac920dcd186101fc557f824b3778f1d106eccedb9ac6da0dbc0d8b2a877009ad49fe8122fad2785fe0aa6101fd557fa6d2475ab64d6ed4622ac8b2baf4f7f012abfc6a8b071d514e3e630d18bd9d956101fe557f54ab9cbdcd0a3541f90c91f4aae82da291dae74a8aa94684248d472166ae0bc56101ff8190556122ba7fbdd5ef9b4bd2e8f26058108a89389b9b33290aecc60583359a67fe011a7d0b0f8190556126a27ffb114fad839c0f5aa9dc1bdbca39e4a10b4e10a5f3cacae15d5d7c2ed7dd89ee8190556127067f803038feb0ad4a457419eee7e9364eb714fbc14c48f946aedd6c0dcb1c45d6eb8190556127107f2d3170b69e13dca408aac2af1957374eb3c1c9f33d1276d50c13e14a11f9dabc556101f76020527fb42ea1e288168e3f76ea47f4d7f3a11a2ab1981ada61ab81835b8279fb621df5929092557f34493726814e245cd07dacaa9d4bc39df7047c7528ca8c64dc4cf4832dc04118556000919091527fad7131ae26494466a8d2bbecfeca6144883c4c75852c61acfdb68294909313335580156119e0576000805461ff001916905550565b61015f546001600160a01b031633146129d45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b5b565b611a466141b5565b606060ca8054610a8f90615a7a565b611863338383614232565b61012d5460ff1615612a3d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b5b565b6002610191541415612a915760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b5b565b6002610191556102005460ff16612b105760405162461bcd60e51b815260206004820152602a60248201527f43616e206e6f7420636c61696d206265666f7265207465616d204e465420646960448201527f73747269627574696f6e000000000000000000000000000000000000000000006064820152608401610b5b565b6000612710612b1e60fd5490565b10612b6b5760405162461bcd60e51b815260206004820152601860248201527f4d617820737570706c79206c696d6974207265616368656400000000000000006044820152606401610b5b565b60005b600481101561302f577fa6d2475ab64d6ed4622ac8b2baf4f7f012abfc6a8b071d514e3e630d18bd9d956101fc8260048110612bba57634e487b7160e01b600052603260045260246000fd5b0154148015612c0a57503360009081526101f960205260408120816101fc8460048110612bf757634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002054115b15612f225760005b600e811015612f1c573360009081526101fa60205260408120816101fc8560048110612c4e57634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002060008381526020019081526020016000205490506000811115612f09576000612ced6101f860006101fc8760048110612ca757634e487b7160e01b600052603260045260246000fd5b015481526020808201929092526040908101600090812087825290925290205461219b612cda866121346064600e613ba3565b6101f660006101fc61217d8b60016133dc565b90506000612d19612d026121e68660016133d0565b61219b60016101f660006101fc6122248c856133dc565b9050612d27600e60026133dc565b841015612dec5760076101f860006101fc8860048110612d5757634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002060008681526020019081526020016000205411158015612d9b575080612d98612d918560016133dc565b84906133d0565b11155b612de75760405162461bcd60e51b815260206004820152601b60248201527f43686170746572204e465420616c726561647920636c61696d656400000000006044820152606401610b5b565b612ed4565b83600d1415612e1457612e008260016133d0565b9150612e0d8160026133d0565b9050612e22565b612e1f8160016133d0565b90505b60086101f860006101fc8860048110612e4b57634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002060008681526020019081526020016000205411158015612e88575080612e85612d918560016133dc565b11155b612ed45760405162461bcd60e51b815260206004820152601b60248201527f43686170746572204e465420616c726561647920636c61696d656400000000006044820152606401610b5b565b612f04336101fc8760048110612efa57634e487b7160e01b600052603260045260246000fd5b0154848688613bbb565b955050505b5080612f1481615ab5565b915050612c12565b5061301d565b3360009081526101f960205260408120816101fc8460048110612f5557634e487b7160e01b600052603260045260246000fd5b0154815260200190815260200160002054111561301d5761301a336101fc8360048110612f9257634e487b7160e01b600052603260045260246000fd5b01546101f760006101fc8660048110612fbb57634e487b7160e01b600052603260045260246000fd5b0154815260208082019290925260409081016000908120543382526101f9909352908120906101fc876004811061300257634e487b7160e01b600052603260045260246000fd5b01548152602001908152602001600020546000613bbb565b91505b8061302781615ab5565b915050612b6e565b50600081116130805760405162461bcd60e51b815260206004820152601360248201527f43616c6c65722063616e6e6f7420636c61696d000000000000000000000000006044820152606401610b5b565b50600161019155565b6130933383613456565b6131055760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610b5b565b61311184848484614301565b50505050565b600081815260cb60205260409020546060906001600160a01b03166131a45760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610b5b565b60006131ae613b40565b905060008151116131ce57604051806020016040528060008152506131f9565b806131d88461437f565b6040516020016131e9929190615881565b6040516020818303038152906040525b9392505050565b60008281526101c3602052604090206001015461321d8133610b1a565b61168083836137c9565b61015f546001600160a01b031633146132825760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b5b565b6001600160a01b0381166132fe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610b5b565b6119e081613b50565b60006001600160e01b031982167f7965db0b000000000000000000000000000000000000000000000000000000001480610a605750610a608261449a565b60008281526101c3602090815260408083206001600160a01b038516845290915290205460ff1661186357613384816001600160a01b031660146144d8565b61338f8360206144d8565b6040516020016133a09291906158b0565b60408051601f198184030181529082905262461bcd60e51b8252610b5b9160040161596d565b6118638282613725565b60006131f982846159d5565b60006131f98284615a20565b600081815260cd6020526040902080546001600160a01b0319166001600160a01b038416908117909155819061341d82611ced565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081815260cb60205260408120546001600160a01b03166134cf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610b5b565b60006134da83611ced565b9050806001600160a01b0316846001600160a01b031614806135155750836001600160a01b031661350a846114da565b6001600160a01b0316145b8061354557506001600160a01b03808216600090815260ce602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661356082611ced565b6001600160a01b0316146135dc5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610b5b565b6001600160a01b0382166136575760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610b5b565b6136628383836146e3565b61366d6000826133e8565b6001600160a01b038316600090815260cc60205260408120805460019290613696908490615a20565b90915550506001600160a01b038216600090815260cc602052604081208054600192906136c49084906159d5565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60008281526101c3602090815260408083206001600160a01b038516845290915290205460ff166118635760008281526101c3602090815260408083206001600160a01b03851684529091529020805460ff191660011790556137853390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526101c3602090815260408083206001600160a01b038516845290915290205460ff16156118635760008281526101c3602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b3361386261015f546001600160a01b031690565b6001600160a01b0316146119e05760405162461bcd60e51b815260206004820152602560248201527f4f6e6c79206f776e65722063616e207570677261646520696d706c656d656e7460448201527f6174696f6e0000000000000000000000000000000000000000000000000000006064820152608401610b5b565b60006139117f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905061391c846146ee565b6000835111806139295750815b1561393a5761393884846147a3565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16613a9b57805460ff191660011781556040516001600160a01b03831660248201526139e790869060440160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f3659cfe6000000000000000000000000000000000000000000000000000000001790526147a3565b50805460ff191681557f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b03838116911614613a925760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201527f75727468657220757067726164657300000000000000000000000000000000006064820152608401610b5b565b613a9b856148a5565b5050505050565b61012d5460ff16613af55760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610b5b565b61012d805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60606101fb8054610a8f90615a7a565b61015f80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006131f982846159ed565b60006131f98284615a01565b60008481526101f66020526040812054613c175760405162461bcd60e51b815260206004820152600e60248201527f526f6c65206e6f742061646465640000000000000000000000000000000000006044820152606401610b5b565b60008581526101f660209081526040808320546101f790925290912054613c3e90856133d0565b1115613c965760405162461bcd60e51b815260206004820152602160248201527f4d617820737570706c79206c696d6974207265616368656420666f72207469656044820152603960f91b6064820152608401610b5b565b6127108410613ce75760405162461bcd60e51b815260206004820152601160248201527f496e76616c6964204e465420496e6465780000000000000000000000000000006044820152606401610b5b565b60005b83811015613e9b57613cfc87866148e5565b613d078560016133d0565b60008781526101f76020526040902054909550613d259060016133d0565b60008781526101f760205260409020556102005460ff16151560011415613d9c576001600160a01b03871660009081526101f960209081526040808320898452909152902054613d769060016133dc565b6001600160a01b03881660009081526101f9602090815260408083208a84529091529020555b613da78260016133d0565b91507fa6d2475ab64d6ed4622ac8b2baf4f7f012abfc6a8b071d514e3e630d18bd9d95861415613e895760008681526101f860209081526040808320868452909152902054613df79060016133d0565b60008781526101f8602090815260408083208784529091529020556102005460ff16151560011415613e89576001600160a01b03871660009081526101fa602090815260408083208984528252808320868452909152902054613e5b9060016133dc565b6001600160a01b03881660009081526101fa602090815260408083208a845282528083208784529091529020555b80613e9381615ab5565b915050613cea565b5095945050505050565b600054610100900460ff1680613ebe575060005460ff16155b613f215760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015613f4c576000805460ff1961ff0019909116610100171660011790555b613f546148ff565b613f5c6148ff565b613f6683836149b9565b8015611680576000805461ff0019169055505050565b600054610100900460ff1680613f95575060005460ff16155b613ff85760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015614023576000805460ff1961ff0019909116610100171660011790555b61402b6148ff565b614033614a9e565b80156119e0576000805461ff001916905550565b600054610100900460ff1680614060575060005460ff16155b6140c35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff161580156140ee576000805460ff1961ff0019909116610100171660011790555b614033614b4e565b600054610100900460ff168061410f575060005460ff16155b6141725760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff1615801561419d576000805460ff1961ff0019909116610100171660011790555b6141a56148ff565b6141ad6148ff565b6140336148ff565b61012d5460ff16156141fc5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b5b565b61012d805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613b233390565b816001600160a01b0316836001600160a01b031614156142945760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610b5b565b6001600160a01b03838116600081815260ce6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61430c84848461354d565b61431884848484614c0f565b6131115760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610b5b565b6060816143a457506040805180820190915260018152600360fc1b6020820152610a63565b8160005b81156143ce57806143b881615ab5565b91506143c79050600a836159ed565b91506143a8565b60008167ffffffffffffffff8111156143f757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614421576020820181803683370190505b5090505b841561354557614436600183615a20565b9150614443600a86615ad0565b61444e9060306159d5565b60f81b81838151811061447157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350614493600a866159ed565b9450614425565b60006001600160e01b031982167f780e9d63000000000000000000000000000000000000000000000000000000001480610a605750610a6082614d67565b606060006144e7836002615a01565b6144f29060026159d5565b67ffffffffffffffff81111561451857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614542576020820181803683370190505b509050600360fc1b8160008151811061456b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106145c457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006145e8846002615a01565b6145f39060016159d5565b90505b6001811115614694577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061464257634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061466657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361468d81615a63565b90506145f6565b5083156131f95760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610b5b565b611680838383614e02565b803b6147625760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610b5b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6148195760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610b5b565b600080846001600160a01b0316846040516148349190615865565b600060405180830381855af49150503d806000811461486f576040519150601f19603f3d011682016040523d82523d6000602084013e614874565b606091505b509150915061489c8282604051806060016040528060278152602001615b3d60279139614ebf565b95945050505050565b6148ae816146ee565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b611863828260405180602001604052806000815250614ef8565b600054610100900460ff1680614918575060005460ff16155b61497b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015614033576000805460ff1961ff00199091166101001716600117905580156119e0576000805461ff001916905550565b600054610100900460ff16806149d2575060005460ff16155b614a355760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015614a60576000805460ff1961ff0019909116610100171660011790555b8251614a739060c990602086019061527e565b508151614a879060ca90602085019061527e565b508015611680576000805461ff0019169055505050565b600054610100900460ff1680614ab7575060005460ff16155b614b1a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015614b45576000805460ff1961ff0019909116610100171660011790555b61403333613b50565b600054610100900460ff1680614b67575060005460ff16155b614bca5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b5b565b600054610100900460ff16158015614bf5576000805460ff1961ff0019909116610100171660011790555b60016101915580156119e0576000805461ff001916905550565b60006001600160a01b0384163b15614d5c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290614c53903390899088908890600401615931565b602060405180830381600087803b158015614c6d57600080fd5b505af1925050508015614c9d575060408051601f3d908101601f19168201909252614c9a918101906157d7565b60015b614d42573d808015614ccb576040519150601f19603f3d011682016040523d82523d6000602084013e614cd0565b606091505b508051614d3a5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610b5b565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050613545565b506001949350505050565b60006001600160e01b031982167f80ac58cd000000000000000000000000000000000000000000000000000000001480614dca57506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610a6057507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b0319831614610a60565b6001600160a01b038316614e5d57614e588160fd8054600083815260fe60205260408120829055600182018355919091527f9346ac6dd7de6b96975fec380d4d994c4c12e6a8897544f22915316cc6cca2800155565b614e80565b816001600160a01b0316836001600160a01b031614614e8057614e808382614f76565b6001600160a01b038216614e9c57614e9781615013565b611680565b826001600160a01b0316826001600160a01b0316146116805761168082826150ec565b60608315614ece5750816131f9565b825115614ede5782518084602001fd5b8160405162461bcd60e51b8152600401610b5b919061596d565b614f028383615130565b614f0f6000848484614c0f565b6116805760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610b5b565b60006001614f8384611d87565b614f8d9190615a20565b600083815260fc6020526040902054909150808214614fe0576001600160a01b038416600090815260fb60209081526040808320858452825280832054848452818420819055835260fc90915290208190555b50600091825260fc602090815260408084208490556001600160a01b03909416835260fb81528383209183525290812055565b60fd5460009061502590600190615a20565b600083815260fe602052604081205460fd805493945090928490811061505b57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060fd838154811061508a57634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260fe909152604080822084905585825281205560fd8054806150d057634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006150f783611d87565b6001600160a01b03909316600090815260fb60209081526040808320868452825280832085905593825260fc9052919091209190915550565b6001600160a01b0382166151865760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610b5b565b600081815260cb60205260409020546001600160a01b0316156151eb5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610b5b565b6151f7600083836146e3565b6001600160a01b038216600090815260cc602052604081208054600192906152209084906159d5565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461528a90615a7a565b90600052602060002090601f0160209004810192826152ac57600085556152f2565b82601f106152c557805160ff19168380011785556152f2565b828001600101855582156152f2579182015b828111156152f25782518255916020019190600101906152d7565b506152fe929150615302565b5090565b5b808211156152fe5760008155600101615303565b600067ffffffffffffffff83111561533157615331615b10565b615344601f8401601f1916602001615980565b905082815283838301111561535857600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b0381168114610a6357600080fd5b600082601f830112615396578081fd5b813560206153ab6153a6836159b1565b615980565b82815281810190858301838502870184018810156153c7578586fd5b855b858110156153ec576153da8261536f565b845292840192908401906001016153c9565b5090979650505050505050565b600082601f830112615409578081fd5b813560206154196153a6836159b1565b8281528181019085830183850287018401881015615435578586fd5b855b858110156153ec57813584529284019290840190600101615437565b600082601f830112615463578081fd5b6131f983833560208501615317565b600060208284031215615483578081fd5b6131f98261536f565b6000806040838503121561549e578081fd5b6154a78361536f565b91506154b56020840161536f565b90509250929050565b6000806000606084860312156154d2578081fd5b6154db8461536f565b92506154e96020850161536f565b9150604084013590509250925092565b6000806000806080858703121561550e578081fd5b6155178561536f565b93506155256020860161536f565b925060408501359150606085013567ffffffffffffffff811115615547578182fd5b61555387828801615453565b91505092959194509250565b60008060408385031215615571578182fd5b61557a8361536f565b91506020830135801515811461558e578182fd5b809150509250929050565b600080604083850312156155ab578182fd5b6155b48361536f565b946020939093013593505050565b6000806000606084860312156155d6578283fd5b6155df8461536f565b95602085013595506040909401359392505050565b60008060408385031215615606578182fd5b61560f8361536f565b9150602083013567ffffffffffffffff81111561562a578182fd5b61563685828601615453565b9150509250929050565b600080600060608486031215615654578081fd5b833567ffffffffffffffff8082111561566b578283fd5b61567787838801615386565b9450602086013591508082111561568c578283fd5b615698878388016153f9565b935060408601359150808211156156ad578283fd5b506156ba868287016153f9565b9150509250925092565b600080600080608085870312156156d9578182fd5b843567ffffffffffffffff808211156156f0578384fd5b6156fc88838901615386565b95506020870135915080821115615711578384fd5b61571d888389016153f9565b94506040870135915080821115615732578384fd5b61573e888389016153f9565b93506060870135915080821115615753578283fd5b50615553878288016153f9565b600060208284031215615771578081fd5b5035919050565b6000806040838503121561578a578182fd5b823591506154b56020840161536f565b600080604083850312156157ac578182fd5b50508035926020909101359150565b6000602082840312156157cc578081fd5b81356131f981615b26565b6000602082840312156157e8578081fd5b81516131f981615b26565b600060208284031215615804578081fd5b813567ffffffffffffffff81111561581a578182fd5b8201601f8101841361582a578182fd5b61354584823560208401615317565b60008151808452615851816020860160208601615a37565b601f01601f19169290920160200192915050565b60008251615877818460208701615a37565b9190910192915050565b60008351615893818460208801615a37565b8351908301906158a7818360208801615a37565b01949350505050565b60007f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000825283516158e8816017850160208801615a37565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615925816028840160208801615a37565b01602801949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526159636080830184615839565b9695505050505050565b6000602082526131f96020830184615839565b604051601f8201601f1916810167ffffffffffffffff811182821017156159a9576159a9615b10565b604052919050565b600067ffffffffffffffff8211156159cb576159cb615b10565b5060209081020190565b600082198211156159e8576159e8615ae4565b500190565b6000826159fc576159fc615afa565b500490565b6000816000190483118215151615615a1b57615a1b615ae4565b500290565b600082821015615a3257615a32615ae4565b500390565b60005b83811015615a52578181015183820152602001615a3a565b838111156131115750506000910152565b600081615a7257615a72615ae4565b506000190190565b600281046001821680615a8e57607f821691505b60208210811415615aaf57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615ac957615ac9615ae4565b5060010190565b600082615adf57615adf615afa565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146119e057600080fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122010b837fea4d0a27ba38887404c3e95fea708753614f12fa6d1d3e2934edb7cf664736f6c63430008020033
[ 4, 7, 15, 22, 5 ]
0xf3db7f7f6419bf537fd24eb530b6eace38850c0c
/* Implements EIP20 token standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md .*/ pragma solidity ^0.4.21; import "./EIP20Interface.sol"; contract BbqCoin is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; function BbqCoin( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014257806318160ddd1461019c57806323b872dd146101c557806327e235e31461023e578063313ce5671461028b5780635c658165146102ba57806370a082311461032657806395d89b4114610373578063a9059cbb14610401578063dd62ed3e1461045b575b600080fd5b34156100bf57600080fd5b6100c76104c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101075780820151818401526020810190506100ec565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014d57600080fd5b610182600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610565565b604051808215151515815260200191505060405180910390f35b34156101a757600080fd5b6101af610657565b6040518082815260200191505060405180910390f35b34156101d057600080fd5b610224600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061065d565b604051808215151515815260200191505060405180910390f35b341561024957600080fd5b610275600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108f7565b6040518082815260200191505060405180910390f35b341561029657600080fd5b61029e61090f565b604051808260ff1660ff16815260200191505060405180910390f35b34156102c557600080fd5b610310600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610922565b6040518082815260200191505060405180910390f35b341561033157600080fd5b61035d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610947565b6040518082815260200191505060405180910390f35b341561037e57600080fd5b610386610990565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103c65780820151818401526020810190506103ab565b50505050905090810190601f1680156103f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561040c57600080fd5b610441600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a2e565b604051808215151515815260200191505060405180910390f35b341561046657600080fd5b6104b1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b87565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561055d5780601f106105325761010080835404028352916020019161055d565b820191906000526020600020905b81548152906001019060200180831161054057829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561072e5750828110155b151561073957600080fd5b82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156108865782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60016020528060005260406000206000915090505481565b600460009054906101000a900460ff1681565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a265780601f106109fb57610100808354040283529160200191610a26565b820191906000526020600020905b815481529060010190602001808311610a0957829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a7e57600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a723058205b044c6f2dedab35f0be1dae46221e9f0600f0cc320433fef1898faf425a5ca50029
[ 38 ]
0xf3dcbc6D72a4E1892f7917b7C43b74131Df8480e
// File: @openzeppelin/contracts/utils/Context.sol // 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; } } // 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: @openzeppelin/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/BDPToken.sol pragma solidity 0.6.12; contract BDPToken is ERC20("BDPToken", "BDP"), Ownable { using SafeMath for uint256; uint256 public NUMBER_BLOCKS_PER_DAY; uint256 public cap = 80000000e18 + 1e18; address public BDPMaster; address public BDPMasterPending; uint public setBDPMasterPendingAtBlock; uint256 public seedPoolAmount = 24000000e18; uint256 constant public PARTNERSHIP_TOTAL_AMOUNT = 20000000e18; uint256 constant public PARTNERSHIP_FIRST_MINT = 8000000e18; uint256 public partnershipAmount = PARTNERSHIP_TOTAL_AMOUNT; uint256 public partnershipMintedAtBlock = 0; uint256 constant public TEAM_TOTAL_AMOUNT = 8000000e18; uint256 public teamAmount = TEAM_TOTAL_AMOUNT; uint256 public teamMintedAtBlock = 0; uint256 constant public FUTURE_TOTAL_AMOUNT = 28000000e18; uint256 constant public FUTURE_EACH_MINT = 9333333e18; uint256 public futureAmount = FUTURE_TOTAL_AMOUNT; uint256 public futureCanMintAtBlock = 0; uint256 public startAtBlock; constructor (uint _startAtBlock, uint _numberBlockPerDay, address _sendTo) public { startAtBlock = _startAtBlock; NUMBER_BLOCKS_PER_DAY = _numberBlockPerDay > 0 ? _numberBlockPerDay : 6000; _mint(_sendTo, 1e18); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { require(totalSupply().add(amount) <= cap, "BDPToken: cap exceeded"); } } function setPendingMaster(address _BDPMaster) public onlyOwner { BDPMasterPending = _BDPMaster; setBDPMasterPendingAtBlock = block.number; } function confirmMaster() public onlyOwner { require(block.number - setBDPMasterPendingAtBlock > 2 * NUMBER_BLOCKS_PER_DAY, "BDPToken: cannot confirm at this time"); BDPMaster = BDPMasterPending; } function setMaster(address _BDPMaster) public onlyOwner { require(BDPMaster == address(0x0), "BDPToken: Cannot set master"); BDPMaster = _BDPMaster; } function mint(address _to, uint256 _amount) public { require(msg.sender == BDPMaster, "BDPToken: only master farmer can mint"); require(seedPoolAmount > 0, "BDPToken: cannot mint for pool"); require(seedPoolAmount >= _amount, "BDPToken: amount greater than limitation"); seedPoolAmount = seedPoolAmount.sub(_amount); _mint(_to, _amount); } function mintForPartnership(address _to) public onlyOwner { uint amount; require(block.number >= startAtBlock + 7 * NUMBER_BLOCKS_PER_DAY, "BDPToken: Cannot mint at this time"); require(partnershipAmount > 0, "BDPToken: Cannot mint more token for partnership"); // This first minting if (partnershipMintedAtBlock == 0) { amount = PARTNERSHIP_FIRST_MINT; partnershipMintedAtBlock = startAtBlock + 7 * NUMBER_BLOCKS_PER_DAY; } else { amount = PARTNERSHIP_TOTAL_AMOUNT .sub(PARTNERSHIP_FIRST_MINT) .mul(block.number - partnershipMintedAtBlock) .div(270 * NUMBER_BLOCKS_PER_DAY); partnershipMintedAtBlock = block.number; } amount = amount < partnershipAmount ? amount : partnershipAmount; partnershipAmount = partnershipAmount.sub(amount); _mint(_to, amount); } function mintForTeam(address _to) public onlyOwner { uint amount; require(block.number >= startAtBlock + 7 * NUMBER_BLOCKS_PER_DAY, "BDPToken: Cannot mint at this time"); require(teamAmount > 0, "BDPToken: Cannot mint more token for team"); // This first minting if (teamMintedAtBlock == 0) { teamMintedAtBlock = startAtBlock + 7 * NUMBER_BLOCKS_PER_DAY; } amount = TEAM_TOTAL_AMOUNT .mul(block.number - teamMintedAtBlock) .div(270 * NUMBER_BLOCKS_PER_DAY); teamMintedAtBlock = block.number; amount = amount < teamAmount ? amount : teamAmount; teamAmount = teamAmount.sub(amount); _mint(_to, amount); } function mintForFutureFarming(address _to) public onlyOwner { require(block.number >= startAtBlock + 56 * NUMBER_BLOCKS_PER_DAY, "BDPToken: Cannot mint at this time"); require(futureAmount > 0, "BDPToken: Cannot mint more token for future farming"); if (block.number >= startAtBlock + 56 * NUMBER_BLOCKS_PER_DAY && futureAmount >= FUTURE_TOTAL_AMOUNT) { _mint(_to, FUTURE_EACH_MINT); futureAmount = futureAmount.sub(FUTURE_EACH_MINT); } if (block.number >= startAtBlock + 86 * NUMBER_BLOCKS_PER_DAY && futureAmount >= FUTURE_TOTAL_AMOUNT.sub(FUTURE_EACH_MINT)) { _mint(_to, FUTURE_EACH_MINT); futureAmount = futureAmount.sub(FUTURE_EACH_MINT); } if (block.number >= startAtBlock + 116 * NUMBER_BLOCKS_PER_DAY && futureAmount > 0) { _mint(_to, futureAmount); futureAmount = 0; } } }
0x608060405234801561001057600080fd5b506004361061023d5760003560e01c8063704393851161013b578063a9059cbb116100b8578063dd62ed3e1161007c578063dd62ed3e14610591578063e5dc5f1a146105bf578063f16daed6146105e5578063f2264a4a146105ed578063f2fde38b146105f55761023d565b8063a9059cbb14610545578063aa4c37d214610571578063d02c9f9314610579578063d5c4c64714610581578063dd3cf226146105895761023d565b80638da5cb5b116100ff5780638da5cb5b14610501578063939ab006146104b357806395d89b4114610509578063a457c2d714610511578063a4aebb3f1461053d5761023d565b806370439385146104bb57806370a08231146104c3578063715018a6146104e95780637265d040146104f157806375993783146104f95761023d565b8063313ce567116101c957806341dcaf341161018d57806341dcaf341461043b578063457217851461044357806352e2c41b146104695780635b1d73501461048d578063701c1955146104b35761023d565b8063313ce56714610397578063355274ea146103b557806339509351146103bd5780633aacd242146103e957806340c10f191461040f5761023d565b806318160ddd1161021057806318160ddd1461032157806323b872dd1461032957806326fae0d31461035f5780632b44b5b4146103875780632f51ca501461038f5761023d565b806306fdde03146102425780630748e052146102bf578063095ea7b3146102d95780631583e3a214610319575b600080fd5b61024a61061b565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561028457818101518382015260200161026c565b50505050905090810190601f1680156102b15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102c76106b1565b60408051918252519081900360200190f35b610305600480360360408110156102ef57600080fd5b506001600160a01b0381351690602001356106b7565b604080519115158252519081900360200190f35b6102c76106d5565b6102c76106db565b6103056004803603606081101561033f57600080fd5b506001600160a01b038135811691602081013590911690604001356106e1565b6103856004803603602081101561037557600080fd5b50356001600160a01b0316610768565b005b6102c761084a565b6102c7610850565b61039f610856565b6040805160ff9092168252519081900360200190f35b6102c761085f565b610305600480360360408110156103d357600080fd5b506001600160a01b038135169060200135610865565b610385600480360360208110156103ff57600080fd5b50356001600160a01b03166108b3565b6103856004803603604081101561042557600080fd5b506001600160a01b038135169060200135610a9f565b6102c7610b9e565b6103856004803603602081101561045957600080fd5b50356001600160a01b0316610bad565b610471610d40565b604080516001600160a01b039092168252519081900360200190f35b610385600480360360208110156104a357600080fd5b50356001600160a01b0316610d4f565b6102c7610eb6565b6102c7610ec5565b6102c7600480360360208110156104d957600080fd5b50356001600160a01b0316610ecb565b610385610ee6565b6102c7610f98565b6102c7610f9e565b610471610fa4565b61024a610fb8565b6103056004803603604081101561052757600080fd5b506001600160a01b038135169060200135611019565b6102c7611081565b6103056004803603604081101561055b57600080fd5b506001600160a01b038135169060200135611087565b61038561109b565b610471611168565b6102c7611177565b6102c761117d565b6102c7600480360360408110156105a757600080fd5b506001600160a01b038135811691602001351661118c565b610385600480360360208110156105d557600080fd5b50356001600160a01b03166111b7565b6102c761123f565b6102c761124e565b6103856004803603602081101561060b57600080fd5b50356001600160a01b0316611254565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106a75780601f1061067c576101008083540402835291602001916106a7565b820191906000526020600020905b81548152906001019060200180831161068a57829003601f168201915b5050505050905090565b60105481565b60006106cb6106c46113c8565b84846113cc565b5060015b92915050565b600d5481565b60025490565b60006106ee8484846114b8565b61075e846106fa6113c8565b61075985604051806060016040528060288152602001611aa9602891396001600160a01b038a166000908152600160205260408120906107386113c8565b6001600160a01b031681526020810191909152604001600020549190611613565b6113cc565b5060019392505050565b6107706113c8565b6001600160a01b0316610781610fa4565b6001600160a01b0316146107ca576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b6008546001600160a01b031615610828576040805162461bcd60e51b815260206004820152601b60248201527f424450546f6b656e3a2043616e6e6f7420736574206d61737465720000000000604482015290519081900360640190fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b600f5481565b600a5481565b60055460ff1690565b60075481565b60006106cb6108726113c8565b8461075985600160006108836113c8565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611362565b6108bb6113c8565b6001600160a01b03166108cc610fa4565b6001600160a01b031614610915576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b6006546038026012540143101561095d5760405162461bcd60e51b815260040180806020018281038252602281526020018061197a6022913960400191505060405180910390fd5b60006010541161099e5760405162461bcd60e51b8152600401808060200182810382526033815260200180611b3e6033913960400191505060405180910390fd5b6006546038026012540143101580156109c457506a17293b0a9e69fd9c00000060105410155b156109fa576109de816a07b868fee9e66dfc3400006116aa565b6010546109f6906a07b868fee9e66dfc34000061179a565b6010555b600654605602601254014310158015610a345750610a2e6a17293b0a9e69fd9c0000006a07b868fee9e66dfc34000061179a565b60105410155b15610a6a57610a4e816a07b868fee9e66dfc3400006116aa565b601054610a66906a07b868fee9e66dfc34000061179a565b6010555b600654607402601254014310158015610a8557506000601054115b15610a9c57610a96816010546116aa565b60006010555b50565b6008546001600160a01b03163314610ae85760405162461bcd60e51b8152600401808060200182810382526025815260200180611a336025913960400191505060405180910390fd5b6000600b5411610b3f576040805162461bcd60e51b815260206004820152601e60248201527f424450546f6b656e3a2063616e6e6f74206d696e7420666f7220706f6f6c0000604482015290519081900360640190fd5b80600b541015610b805760405162461bcd60e51b8152600401808060200182810382526028815260200180611af16028913960400191505060405180910390fd5b600b54610b8d908261179a565b600b55610b9a82826116aa565b5050565b6a07b868fee9e66dfc34000081565b610bb56113c8565b6001600160a01b0316610bc6610fa4565b6001600160a01b031614610c0f576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b600060065460070260125401431015610c595760405162461bcd60e51b815260040180806020018281038252602281526020018061197a6022913960400191505060405180910390fd5b6000600c5411610c9a5760405162461bcd60e51b8152600401808060200182810382526030815260200180611a586030913960400191505060405180910390fd5b600d54610cc25750600654601254600790910201600d556a069e10de76676d08000000610d10565b610d0960065461010e02610d03600d544303610cfd6a069e10de76676d080000006a108b2a2c2802909400000061179a90919063ffffffff16565b906117f7565b90611850565b43600d5590505b600c548110610d2157600c54610d23565b805b600c54909150610d33908261179a565b600c55610b9a82826116aa565b6008546001600160a01b031681565b610d576113c8565b6001600160a01b0316610d68610fa4565b6001600160a01b031614610db1576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b600060065460070260125401431015610dfb5760405162461bcd60e51b815260040180806020018281038252602281526020018061197a6022913960400191505060405180910390fd5b6000600e5411610e3c5760405162461bcd60e51b81526004018080602001828103825260298152602001806119e46029913960400191505060405180910390fd5b600f54610e5357600654601254600790910201600f555b610e7f60065461010e02610d03600f5443036a069e10de76676d080000006117f790919063ffffffff16565b43600f55600e549091508110610e9757600e54610e99565b805b600e54909150610ea9908261179a565b600e55610b9a82826116aa565b6a069e10de76676d0800000081565b600e5481565b6001600160a01b031660009081526020819052604090205490565b610eee6113c8565b6001600160a01b0316610eff610fa4565b6001600160a01b031614610f48576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b60125481565b600b5481565b60055461010090046001600160a01b031690565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106a75780601f1061067c576101008083540402835291602001916106a7565b60006106cb6110266113c8565b8461075985604051806060016040528060258152602001611b9560259139600160006110506113c8565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611613565b600c5481565b60006106cb6110946113c8565b84846114b8565b6110a36113c8565b6001600160a01b03166110b4610fa4565b6001600160a01b0316146110fd576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b600654600202600a544303116111445760405162461bcd60e51b81526004018080602001828103825260258152602001806119556025913960400191505060405180910390fd5b600954600880546001600160a01b0319166001600160a01b03909216919091179055565b6009546001600160a01b031681565b60065481565b6a108b2a2c2802909400000081565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6111bf6113c8565b6001600160a01b03166111d0610fa4565b6001600160a01b031614611219576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b600980546001600160a01b0319166001600160a01b039290921691909117905543600a55565b6a17293b0a9e69fd9c00000081565b60115481565b61125c6113c8565b6001600160a01b031661126d610fa4565b6001600160a01b0316146112b6576040805162461bcd60e51b81526020600482018190526024820152600080516020611ad1833981519152604482015290519081900360640190fd5b6001600160a01b0381166112fb5760405162461bcd60e51b815260040180806020018281038252602681526020018061199c6026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6000828201838110156113bc576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b505050565b3390565b6001600160a01b0383166114115760405162461bcd60e51b8152600401808060200182810382526024815260200180611b716024913960400191505060405180910390fd5b6001600160a01b0382166114565760405162461bcd60e51b81526004018080602001828103825260228152602001806119c26022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166114fd5760405162461bcd60e51b8152600401808060200182810382526025815260200180611b196025913960400191505060405180910390fd5b6001600160a01b0382166115425760405162461bcd60e51b81526004018080602001828103825260238152602001806119326023913960400191505060405180910390fd5b61154d8383836118b7565b61158a81604051806060016040528060268152602001611a0d602691396001600160a01b0386166000908152602081905260409020549190611613565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546115b99082611362565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156116a25760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561166757818101518382015260200161164f565b50505050905090810190601f1680156116945780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b038216611705576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b611711600083836118b7565b60025461171e9082611362565b6002556001600160a01b0382166000908152602081905260409020546117449082611362565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000828211156117f1576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082611806575060006106cf565b8282028284828161181357fe5b04146113bc5760405162461bcd60e51b8152600401808060200182810382526021815260200180611a886021913960400191505060405180910390fd5b60008082116118a6576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816118af57fe5b049392505050565b6118c28383836113c3565b6001600160a01b0383166113c3576007546118e5826118df6106db565b90611362565b11156113c3576040805162461bcd60e51b8152602060048201526016602482015275109114151bdad95b8e8818d85c08195e18d95959195960521b604482015290519081900360640190fdfe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373424450546f6b656e3a2063616e6e6f7420636f6e6669726d20617420746869732074696d65424450546f6b656e3a2043616e6e6f74206d696e7420617420746869732074696d654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373424450546f6b656e3a2043616e6e6f74206d696e74206d6f726520746f6b656e20666f72207465616d45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365424450546f6b656e3a206f6e6c79206d6173746572206661726d65722063616e206d696e74424450546f6b656e3a2043616e6e6f74206d696e74206d6f726520746f6b656e20666f7220706172746e657273686970536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572424450546f6b656e3a20616d6f756e742067726561746572207468616e206c696d69746174696f6e45524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373424450546f6b656e3a2043616e6e6f74206d696e74206d6f726520746f6b656e20666f7220667574757265206661726d696e6745524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122059413b0d99abc1d253eca9ab972f0c21d2569f48307874c0709e05cd5dfbcc6864736f6c634300060c0033
[ 38 ]
0xF3DDdB0042177C7766f4610C994Ea63E0c2A5a07
// 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 ]
0xf3dde07e3330744fda1ea8a860b87e87d000aae5
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 = 29289600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x2cB2AaE5b70df7F97D58446FCc1d01659604C613 ; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820a752e96d3ae6f1f7e7d9bcb72067aa74ce60b738fbbb1e5e5da932fff2694b1a0029
[ 16, 7 ]
0xf3dde53e8477b414e298c008af0ce4a8a25399b1
pragma solidity ^0.4.18; /* import "./EIP20Interface.sol"; */ contract EIP20Interface { /* This is a slight change to the ERC20 base standard. function totalSupply() constant returns (uint256 supply); is replaced with: uint256 public totalSupply; This automatically creates a getter function for the totalSupply. This is moved to the base contract since public getter functions are not currently recognised as an implementation of the matching abstract function by the compiler. */ /// total amount of tokens uint256 public totalSupply; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); // solhint-disable-next-line no-simple-event-func-name event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract TridentToken is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. string public symbol; //An identifier: eg SBX function TridentToken( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
0x6060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014257806318160ddd1461019c57806323b872dd146101c557806327e235e31461023e578063313ce5671461028b5780635c658165146102ba57806370a082311461032657806395d89b4114610373578063a9059cbb14610401578063dd62ed3e1461045b575b600080fd5b34156100bf57600080fd5b6100c76104c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101075780820151818401526020810190506100ec565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014d57600080fd5b610182600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610565565b604051808215151515815260200191505060405180910390f35b34156101a757600080fd5b6101af610657565b6040518082815260200191505060405180910390f35b34156101d057600080fd5b610224600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061065d565b604051808215151515815260200191505060405180910390f35b341561024957600080fd5b610275600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108f7565b6040518082815260200191505060405180910390f35b341561029657600080fd5b61029e61090f565b604051808260ff1660ff16815260200191505060405180910390f35b34156102c557600080fd5b610310600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610922565b6040518082815260200191505060405180910390f35b341561033157600080fd5b61035d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610947565b6040518082815260200191505060405180910390f35b341561037e57600080fd5b610386610990565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103c65780820151818401526020810190506103ab565b50505050905090810190601f1680156103f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561040c57600080fd5b610441600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610a2e565b604051808215151515815260200191505060405180910390f35b341561046657600080fd5b6104b1600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610b87565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561055d5780601f106105325761010080835404028352916020019161055d565b820191906000526020600020905b81548152906001019060200180831161054057829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561072e5750828110155b151561073957600080fd5b82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156108865782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60016020528060005260406000206000915090505481565b600460009054906101000a900460ff1681565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a265780601f106109fb57610100808354040283529160200191610a26565b820191906000526020600020905b815481529060010190602001808311610a0957829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610a7e57600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582063ab06a7cd51780727b0c52fa701078f07d96b45d335d90f3f17a59ebf0c6a340029
[ 38 ]
0xf3de78b2430473c151a4e00777f1ab4f4bc51b25
/** *Submitted for verification at Etherscan.io on 2021-06-11 */ // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/token/ERC20/IERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/utils/Context.sol pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/solc-0.6/contracts/access/Ownable.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: AdvisoryReserves.sol pragma solidity 0.6.11; contract AdvisoryReserves is Ownable { /// @notice An event thats emitted when tokens are withdrawn to an address event TokensTransferred(address indexed receiver, uint amount); /// @notice dmod token address address public immutable dmodToken; /// @notice identifier for the contract string public identifier; /** * @notice Construct a new Reserve Contract * @param _dmodToken dmod token address */ constructor(address _dmodToken, string memory _identifier) public { dmodToken = _dmodToken; identifier = _identifier; } /** * @dev Withdraw remaining tokens to an address * @param receiver Address of account to withdraw from * @param amount Amount of tokens to withdraw */ function transferTokensToAddress(address receiver, uint amount) external onlyOwner { require(receiver != address(0), "Reserves::transferTokensToAddress: receiver is zero address"); require(amount > 0, "Reserves::transferTokensToAddress: amount is zero"); IERC20 dmodTokenInstance = IERC20(dmodToken); dmodTokenInstance.transfer(receiver, amount); emit TokensTransferred(receiver, amount); } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c80634c65d2d214610067578063715018a6146100b55780637998a1c4146100bf5780638da5cb5b14610142578063a39f57601461018c578063f2fde38b146101d6575b600080fd5b6100b36004803603604081101561007d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061021a565b005b6100bd6104e3565b005b6100c7610651565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101075780820151818401526020810190506100ec565b50505050905090810190601f1680156101345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61014a6106ef565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610194610718565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610218600480360360208110156101ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061073c565b005b61022261092f565b73ffffffffffffffffffffffffffffffffffffffff166102406106ef565b73ffffffffffffffffffffffffffffffffffffffff16146102c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561034f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603b81526020018061095e603b913960400191505060405180910390fd5b600081116103a8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806109996031913960400191505060405180910390fd5b60007f0000000000000000000000005f6c5c2fb289db2228d159c69621215e354218d790508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561045457600080fd5b505af1158015610468573d6000803e3d6000fd5b505050506040513d602081101561047e57600080fd5b8101908080519060200190929190505050508273ffffffffffffffffffffffffffffffffffffffff167f12f4533b5cbd2c9f8a0752a2d0b16379af992dbb2a0844a5007a19d983b3a934836040518082815260200191505060405180910390a2505050565b6104eb61092f565b73ffffffffffffffffffffffffffffffffffffffff166105096106ef565b73ffffffffffffffffffffffffffffffffffffffff1614610592576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106e75780601f106106bc576101008083540402835291602001916106e7565b820191906000526020600020905b8154815290600101906020018083116106ca57829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f0000000000000000000000005f6c5c2fb289db2228d159c69621215e354218d781565b61074461092f565b73ffffffffffffffffffffffffffffffffffffffff166107626106ef565b73ffffffffffffffffffffffffffffffffffffffff16146107eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610871576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806109386026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60003390509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737352657365727665733a3a7472616e73666572546f6b656e73546f416464726573733a207265636569766572206973207a65726f206164647265737352657365727665733a3a7472616e73666572546f6b656e73546f416464726573733a20616d6f756e74206973207a65726fa2646970667358221220f5e14aa956beed935de1d37c98ac583283870f1b5232a30e47b2e51679a54f5e64736f6c634300060b0033
[ 16 ]
0xf3dea48690f3e8f7f676cfb2798254d3225b9386
/** Grind Token 2021 grindtoken.io */ pragma solidity ^0.6.12; // SPDX-License-Identifier: Unlicensed interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval( address indexed owner, address indexed spender, uint256 value ); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require( address(this).balance >= amount, "Address: insufficient balance" ); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, "Address: low-level call with value failed" ); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require( address(this).balance >= value, "Address: insufficient balance for call" ); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue( address target, bytes memory data, uint256 weiValue, string memory errorMessage ) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: weiValue}( data ); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = now + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require( _previousOwner == msg.sender, "You don't have permission to unlock" ); require(now > _lockTime, "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); 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(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); 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, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 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 (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 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 (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); 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 (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETH( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountToken, uint256 amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountA, uint256 amountB); function removeLiquidityETHWithPermit( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountToken, uint256 amountETH); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapTokensForExactTokens( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapTokensForExactETH( uint256 amountOut, uint256 amountInMax, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapETHForExactTokens( uint256 amountOut, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint256 amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } /** * @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() public onlyOwner whenNotPaused { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract GRIND is Context, IERC20, Ownable, Pausable { using SafeMath for uint256; using Address for address; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; mapping(address => bool) private _isBlackListedBot; address[] private _blackListedBots; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 15 * 10**9 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Grind Token"; string private _symbol = "GRIND"; uint8 private _decimals = 9; uint256 public _taxFee = 4; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 2; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; address payable public _charityWalletAddress; address payable public _marketingWalletAddress; address payable public _devWalletAddress; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 4 * 10**9 * 10**9; uint256 private numTokensSellToAddToLiquidity = 4 * 10**7 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event DistributeRewards( uint256 charityPercentage, uint256 mmPercentage, uint256 devPercentage ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor( address payable charityWalletAddress, address payable marketingWalletAddress, address payable devWalletAddress ) public { _charityWalletAddress = charityWalletAddress; _marketingWalletAddress = marketingWalletAddress; _devWalletAddress = devWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; //blacklist bots _isBlackListedBot[ address(0x3DAd8cf200799F82fD8eb68f608220d8f3eBF8De) ] = true; _blackListedBots.push( address(0x3DAd8cf200799F82fD8eb68f608220d8f3eBF8De) ); 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 excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function 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 addBotToBlacklist(address account) external onlyOwner() { require( account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, "We cannot blacklist UniSwap router" ); require(!_isBlackListedBot[account], "Account is already blacklisted"); _isBlackListedBot[account] = true; _blackListedBots.push(account); } function removeBotFromBlacklist(address account) external onlyOwner() { require(_isBlackListedBot[account], "Account is not blacklisted"); for (uint256 i = 0; i < _blackListedBots.length; i++) { if (_blackListedBots[i] == account) { _blackListedBots[i] = _blackListedBots[ _blackListedBots.length - 1 ]; _isBlackListedBot[account] = false; _blackListedBots.pop(); break; } } } function setRouterAddress(address newRouter) public onlyOwner() { IUniswapV2Router02 _newUniswapRouter = IUniswapV2Router02(newRouter); uniswapV2Pair = IUniswapV2Factory(_newUniswapRouter.factory()) .createPair(address(this), _newUniswapRouter.WETH()); uniswapV2Router = _newUniswapRouter; } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { ( uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues( tAmount, tFee, tLiquidity, _getRate() ); return ( rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity ); } function _getTValues(uint256 tAmount) private view returns ( uint256, uint256, uint256 ) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if ( _rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns (bool) { return _isExcludedFromFee[account]; } function _setCharityWallet(address payable charityWalletAddress) external onlyOwner() { _charityWalletAddress = charityWalletAddress; } function sendETHToCharity(uint256 amount) private { swapTokensForEth(amount); _charityWalletAddress.transfer(address(this).balance); } function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() { _marketingWalletAddress = marketingWalletAddress; } function sendETHToMarketing(uint256 amount) private { swapTokensForEth(amount); _marketingWalletAddress.transfer(address(this).balance); } function _setDevWallet(address payable devWalletAddress) external onlyOwner() { _devWalletAddress = devWalletAddress; } function sendETHToDev(uint256 amount) private { swapTokensForEth(amount); _devWalletAddress.transfer(address(this).balance); } 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(!_isBlackListedBot[to], "You are blacklisted"); require(!_isBlackListedBot[msg.sender], "You are blacklisted"); require(!_isBlackListedBot[tx.origin], "You are blacklisted"); if (from != owner() && to != owner()) require( amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount." ); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from, to, amount, takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 charityPercentage = contractTokenBalance.div(10000).mul(1875); uint256 devPercentage = contractTokenBalance.div(1000).mul(375); uint256 mmPercentage = contractTokenBalance.div(10000).mul(4375); //send ETH to specified wallets sendETHToCharity(charityPercentage); sendETHToMarketing(mmPercentage); sendETHToDev(devPercentage); emit DistributeRewards(charityPercentage, mmPercentage, devPercentage); } 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, path, address(this), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102b25760003560e01c80635342acb411610175578063a457c2d7116100dc578063c49b9a8011610095578063dd4670641161006f578063dd46706414610a01578063dd62ed3e14610a2b578063ea2f0b3714610a66578063f2fde38b14610a99576102b9565b8063c49b9a8014610978578063d047e4b7146109a4578063d543dbeb146109d7576102b9565b8063a457c2d714610894578063a69df4b5146108cd578063a9059cbb146108e2578063b030b34a1461091b578063b425bac31461094e578063b6c5232414610963576102b9565b80637d1db4a51161012e5780637d1db4a5146107e35780638456cb59146107f857806388f820201461080d5780638da5cb5b146108405780638ee88c531461085557806395d89b411461087f576102b9565b80635342acb4146107295780635c975abb1461075c5780636bc87c3a1461077157806370a0823114610786578063715018a6146107b957806376d4ab99146107ce576102b9565b80633685d4191161021957806341cb87fc116101d257806341cb87fc14610634578063437823ec146106675780634549b0391461069a57806349bd5a5e146106cc5780634a74bb02146106e157806352390c02146106f6576102b9565b80633685d4191461055f57806339509351146105925780633b124fe7146105cb5780633bd5d173146105e05780633f4ba83a1461060a5780634144d9e41461061f576102b9565b806318160ddd1161026b57806318160ddd1461044c5780631d7ef879146104615780631ff53b601461049457806323b872dd146104c75780632d8381191461050a578063313ce56714610534576102b9565b8063061c82d0146102be57806306fdde03146102ea578063095ea7b3146103745780630a1f8ea8146103c157806313114a9d146103f45780631694505e1461041b576102b9565b366102b957005b600080fd5b3480156102ca57600080fd5b506102e8600480360360208110156102e157600080fd5b5035610acc565b005b3480156102f657600080fd5b506102ff610b29565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610339578181015183820152602001610321565b50505050905090810190601f1680156103665780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561038057600080fd5b506103ad6004803603604081101561039757600080fd5b506001600160a01b038135169060200135610bbf565b604080519115158252519081900360200190f35b3480156103cd57600080fd5b506102e8600480360360208110156103e457600080fd5b50356001600160a01b0316610bdd565b34801561040057600080fd5b50610409610c57565b60408051918252519081900360200190f35b34801561042757600080fd5b50610430610c5d565b604080516001600160a01b039092168252519081900360200190f35b34801561045857600080fd5b50610409610c6c565b34801561046d57600080fd5b506102e86004803603602081101561048457600080fd5b50356001600160a01b0316610c72565b3480156104a057600080fd5b506102e8600480360360208110156104b757600080fd5b50356001600160a01b0316610dfa565b3480156104d357600080fd5b506103ad600480360360608110156104ea57600080fd5b506001600160a01b03813581169160208101359091169060400135610e74565b34801561051657600080fd5b506104096004803603602081101561052d57600080fd5b5035610efb565b34801561054057600080fd5b50610549610f5d565b6040805160ff9092168252519081900360200190f35b34801561056b57600080fd5b506102e86004803603602081101561058257600080fd5b50356001600160a01b0316610f66565b34801561059e57600080fd5b506103ad600480360360408110156105b557600080fd5b506001600160a01b038135169060200135611127565b3480156105d757600080fd5b50610409611175565b3480156105ec57600080fd5b506102e86004803603602081101561060357600080fd5b503561117b565b34801561061657600080fd5b506102e8611255565b34801561062b57600080fd5b506104306112f1565b34801561064057600080fd5b506102e86004803603602081101561065757600080fd5b50356001600160a01b0316611300565b34801561067357600080fd5b506102e86004803603602081101561068a57600080fd5b50356001600160a01b03166114ea565b3480156106a657600080fd5b50610409600480360360408110156106bd57600080fd5b50803590602001351515611566565b3480156106d857600080fd5b506104306115f8565b3480156106ed57600080fd5b506103ad611607565b34801561070257600080fd5b506102e86004803603602081101561071957600080fd5b50356001600160a01b0316611617565b34801561073557600080fd5b506103ad6004803603602081101561074c57600080fd5b50356001600160a01b031661179d565b34801561076857600080fd5b506103ad6117bb565b34801561077d57600080fd5b506104096117c4565b34801561079257600080fd5b50610409600480360360208110156107a957600080fd5b50356001600160a01b03166117ca565b3480156107c557600080fd5b506102e861182c565b3480156107da57600080fd5b506104306118bc565b3480156107ef57600080fd5b506104096118cb565b34801561080457600080fd5b506102e86118d1565b34801561081957600080fd5b506103ad6004803603602081101561083057600080fd5b50356001600160a01b0316611971565b34801561084c57600080fd5b5061043061198f565b34801561086157600080fd5b506102e86004803603602081101561087857600080fd5b503561199e565b34801561088b57600080fd5b506102ff6119fb565b3480156108a057600080fd5b506103ad600480360360408110156108b757600080fd5b506001600160a01b038135169060200135611a5c565b3480156108d957600080fd5b506102e8611ac4565b3480156108ee57600080fd5b506103ad6004803603604081101561090557600080fd5b506001600160a01b038135169060200135611bb2565b34801561092757600080fd5b506102e86004803603602081101561093e57600080fd5b50356001600160a01b0316611bc6565b34801561095a57600080fd5b50610430611d53565b34801561096f57600080fd5b50610409611d62565b34801561098457600080fd5b506102e86004803603602081101561099b57600080fd5b50351515611d68565b3480156109b057600080fd5b506102e8600480360360208110156109c757600080fd5b50356001600160a01b0316611e13565b3480156109e357600080fd5b506102e8600480360360208110156109fa57600080fd5b5035611e8d565b348015610a0d57600080fd5b506102e860048036036020811015610a2457600080fd5b5035611f0b565b348015610a3757600080fd5b5061040960048036036040811015610a4e57600080fd5b506001600160a01b0381358116916020013516611fa9565b348015610a7257600080fd5b506102e860048036036020811015610a8957600080fd5b50356001600160a01b0316611fd4565b348015610aa557600080fd5b506102e860048036036020811015610abc57600080fd5b50356001600160a01b031661204d565b610ad4612133565b6000546001600160a01b03908116911614610b24576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b601255565b600f8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610bb55780601f10610b8a57610100808354040283529160200191610bb5565b820191906000526020600020905b815481529060010190602001808311610b9857829003601f168201915b5050505050905090565b6000610bd3610bcc612133565b8484612137565b5060015b92915050565b610be5612133565b6000546001600160a01b03908116911614610c35576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b601a80546001600160a01b0319166001600160a01b0392909216919091179055565b600e5490565b6016546001600160a01b031681565b600c5490565b610c7a612133565b6000546001600160a01b03908116911614610cca576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0382161415610d265760405162461bcd60e51b815260040180806020018281038252602281526020018061333a6022913960400191505060405180910390fd5b6001600160a01b0381166000908152600a602052604090205460ff1615610d94576040805162461bcd60e51b815260206004820152601e60248201527f4163636f756e7420697320616c726561647920626c61636b6c69737465640000604482015290519081900360640190fd5b6001600160a01b03166000818152600a60205260408120805460ff19166001908117909155600b805491820181559091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b0319169091179055565b610e02612133565b6000546001600160a01b03908116911614610e52576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b601980546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e81848484612223565b610ef184610e8d612133565b610eec8560405180606001604052806028815260200161335c602891396001600160a01b038a16600090815260066020526040812090610ecb612133565b6001600160a01b031681526020810191909152604001600020549190612568565b612137565b5060019392505050565b6000600d54821115610f3e5760405162461bcd60e51b815260040180806020018281038252602a81526020018061327f602a913960400191505060405180910390fd5b6000610f486125ff565b9050610f548382612622565b9150505b919050565b60115460ff1690565b610f6e612133565b6000546001600160a01b03908116911614610fbe576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526008602052604090205460ff1661102b576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b60095481101561112357816001600160a01b03166009828154811061104f57fe5b6000918252602090912001546001600160a01b0316141561111b5760098054600019810190811061107c57fe5b600091825260209091200154600980546001600160a01b0390921691839081106110a257fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600582526040808220829055600890925220805460ff1916905560098054806110f457fe5b600082815260209020810160001990810180546001600160a01b0319169055019055611123565b60010161102e565b5050565b6000610bd3611134612133565b84610eec8560066000611145612133565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061266b565b60125481565b6000611185612133565b6001600160a01b03811660009081526008602052604090205490915060ff16156111e05760405162461bcd60e51b815260040180806020018281038252602c815260200180613436602c913960400191505060405180910390fd5b60006111eb836126c5565b505050506001600160a01b03841660009081526004602052604090205491925061121791905082612714565b6001600160a01b038316600090815260046020526040902055600d5461123d9082612714565b600d55600e5461124d908461266b565b600e55505050565b61125d612133565b6000546001600160a01b039081169116146112ad576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b60035460ff166112bc57600080fd5b6003805460ff191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b6019546001600160a01b031681565b611308612133565b6000546001600160a01b03908116911614611358576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6000819050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561139657600080fd5b505afa1580156113aa573d6000803e3d6000fd5b505050506040513d60208110156113c057600080fd5b5051604080516315ab88c960e31b815290516001600160a01b039283169263c9c653969230929186169163ad5c464891600480820192602092909190829003018186803b15801561141057600080fd5b505afa158015611424573d6000803e3d6000fd5b505050506040513d602081101561143a57600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301525160448083019260209291908290030181600087803b15801561148c57600080fd5b505af11580156114a0573d6000803e3d6000fd5b505050506040513d60208110156114b657600080fd5b5051601780546001600160a01b039283166001600160a01b0319918216179091556016805493909216921691909117905550565b6114f2612133565b6000546001600160a01b03908116911614611542576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600760205260409020805460ff19166001179055565b6000600c548311156115bf576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b816115de5760006115cf846126c5565b50939550610bd7945050505050565b60006115e9846126c5565b50929550610bd7945050505050565b6017546001600160a01b031681565b601a54600160a81b900460ff1681565b61161f612133565b6000546001600160a01b0390811691161461166f576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526008602052604090205460ff16156116dd576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205415611737576001600160a01b03811660009081526004602052604090205461171d90610efb565b6001600160a01b0382166000908152600560205260409020555b6001600160a01b03166000818152600860205260408120805460ff191660019081179091556009805491820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319169091179055565b6001600160a01b031660009081526007602052604090205460ff1690565b60035460ff1681565b60145481565b6001600160a01b03811660009081526008602052604081205460ff161561180a57506001600160a01b038116600090815260056020526040902054610f58565b6001600160a01b038216600090815260046020526040902054610bd790610efb565b611834612133565b6000546001600160a01b03908116911614611884576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116906000805160206133a4833981519152908390a3600080546001600160a01b0319169055565b6018546001600160a01b031681565b601b5481565b6118d9612133565b6000546001600160a01b03908116911614611929576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b60035460ff161561193957600080fd5b6003805460ff191660011790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b6001600160a01b031660009081526008602052604090205460ff1690565b6000546001600160a01b031690565b6119a6612133565b6000546001600160a01b039081169116146119f6576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b601455565b60108054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610bb55780601f10610b8a57610100808354040283529160200191610bb5565b6000610bd3611a69612133565b84610eec856040518060600160405280602581526020016134856025913960066000611a93612133565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612568565b6001546001600160a01b03163314611b0d5760405162461bcd60e51b81526004018080602001828103825260238152602001806134626023913960400191505060405180910390fd5b6002544211611b63576040805162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c2037206461797300604482015290519081900360640190fd5b600154600080546040516001600160a01b0393841693909116916000805160206133a483398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610bd3611bbf612133565b8484612223565b611bce612133565b6000546001600160a01b03908116911614611c1e576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6001600160a01b0381166000908152600a602052604090205460ff16611c8b576040805162461bcd60e51b815260206004820152601a60248201527f4163636f756e74206973206e6f7420626c61636b6c6973746564000000000000604482015290519081900360640190fd5b60005b600b5481101561112357816001600160a01b0316600b8281548110611caf57fe5b6000918252602090912001546001600160a01b03161415611d4b57600b80546000198101908110611cdc57fe5b600091825260209091200154600b80546001600160a01b039092169183908110611d0257fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600a90915260409020805460ff19169055600b8054806110f457fe5b600101611c8e565b601a546001600160a01b031681565b60025490565b611d70612133565b6000546001600160a01b03908116911614611dc0576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b601a8054821515600160a81b810260ff60a81b199092169190911790915560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a150565b611e1b612133565b6000546001600160a01b03908116911614611e6b576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b601880546001600160a01b0319166001600160a01b0392909216919091179055565b611e95612133565b6000546001600160a01b03908116911614611ee5576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b611f056064611eff83600c5461275690919063ffffffff16565b90612622565b601b5550565b611f13612133565b6000546001600160a01b03908116911614611f63576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b60008054600180546001600160a01b03199081166001600160a01b0384161790915516815542820160025560405181906000805160206133a4833981519152908290a350565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b611fdc612133565b6000546001600160a01b0390811691161461202c576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600760205260409020805460ff19169055565b612055612133565b6000546001600160a01b039081169116146120a5576040805162461bcd60e51b81526020600482018190526024820152600080516020613384833981519152604482015290519081900360640190fd5b6001600160a01b0381166120ea5760405162461bcd60e51b81526004018080602001828103825260268152602001806132a96026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216916000805160206133a483398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b03831661217c5760405162461bcd60e51b81526004018080602001828103825260248152602001806134126024913960400191505060405180910390fd5b6001600160a01b0382166121c15760405162461bcd60e51b81526004018080602001828103825260228152602001806132cf6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260066020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166122685760405162461bcd60e51b81526004018080602001828103825260258152602001806133ed6025913960400191505060405180910390fd5b6001600160a01b0382166122ad5760405162461bcd60e51b815260040180806020018281038252602381526020018061325c6023913960400191505060405180910390fd5b600081116122ec5760405162461bcd60e51b81526004018080602001828103825260298152602001806133c46029913960400191505060405180910390fd5b6001600160a01b0382166000908152600a602052604090205460ff1615612350576040805162461bcd60e51b8152602060048201526013602482015272165bdd48185c9948189b1858dadb1a5cdd1959606a1b604482015290519081900360640190fd5b336000908152600a602052604090205460ff16156123ab576040805162461bcd60e51b8152602060048201526013602482015272165bdd48185c9948189b1858dadb1a5cdd1959606a1b604482015290519081900360640190fd5b326000908152600a602052604090205460ff1615612406576040805162461bcd60e51b8152602060048201526013602482015272165bdd48185c9948189b1858dadb1a5cdd1959606a1b604482015290519081900360640190fd5b61240e61198f565b6001600160a01b0316836001600160a01b031614158015612448575061243261198f565b6001600160a01b0316826001600160a01b031614155b1561248e57601b5481111561248e5760405162461bcd60e51b81526004018080602001828103825260288152602001806132f16028913960400191505060405180910390fd5b6000612499306117ca565b9050601b5481106124a95750601b545b601c54811080159081906124c75750601a54600160a01b900460ff16155b80156124e157506017546001600160a01b03868116911614155b80156124f65750601a54600160a81b900460ff165b1561250957601c549150612509826127af565b6001600160a01b03851660009081526007602052604090205460019060ff168061254b57506001600160a01b03851660009081526007602052604090205460ff165b15612554575060005b61256086868684612878565b505050505050565b600081848411156125f75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156125bc5781810151838201526020016125a4565b50505050905090810190601f1680156125e95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600080600061260c6129ec565b909250905061261b8282612622565b9250505090565b600061266483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b4f565b9392505050565b600082820183811015612664576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008060008060008060008060006126dc8a612bb4565b92509250925060008060006126fa8d86866126f56125ff565b612bf6565b919f909e50909c50959a5093985091965092945050505050565b600061266483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612568565b60008261276557506000610bd7565b8282028284828161277257fe5b04146126645760405162461bcd60e51b81526004018080602001828103825260218152602001806133196021913960400191505060405180910390fd5b601a805460ff60a01b1916600160a01b17905560006127dc6107536127d684612710612622565b90612756565b905060006127f26101776127d6856103e8612622565b905060006128086111176127d686612710612622565b905061281383612c46565b61281c81612c88565b61282582612cca565b604080518481526020810183905280820184905290517f2b3815017a53df0f7a02daff8930fa0330e6091a501c5de817e0df95894bab1d9181900360600190a15050601a805460ff60a01b191690555050565b8061288557612885612d0c565b6001600160a01b03841660009081526008602052604090205460ff1680156128c657506001600160a01b03831660009081526008602052604090205460ff16155b156128db576128d6848484612d3e565b6129d9565b6001600160a01b03841660009081526008602052604090205460ff1615801561291c57506001600160a01b03831660009081526008602052604090205460ff165b1561292c576128d6848484612e62565b6001600160a01b03841660009081526008602052604090205460ff1615801561296e57506001600160a01b03831660009081526008602052604090205460ff16155b1561297e576128d6848484612f0b565b6001600160a01b03841660009081526008602052604090205460ff1680156129be57506001600160a01b03831660009081526008602052604090205460ff165b156129ce576128d6848484612f4f565b6129d9848484612f0b565b806129e6576129e6612fc2565b50505050565b600d54600c546000918291825b600954811015612b1d57826004600060098481548110612a1557fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180612a7a5750816005600060098481548110612a5357fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15612a9157600d54600c5494509450505050612b4b565b612ad16004600060098481548110612aa557fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612714565b9250612b136005600060098481548110612ae757fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612714565b91506001016129f9565b50600c54600d54612b2d91612622565b821015612b4557600d54600c54935093505050612b4b565b90925090505b9091565b60008183612b9e5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156125bc5781810151838201526020016125a4565b506000838581612baa57fe5b0495945050505050565b600080600080612bc385612fd0565b90506000612bd086612fec565b90506000612be882612be28986612714565b90612714565b979296509094509092505050565b6000808080612c058886612756565b90506000612c138887612756565b90506000612c218888612756565b90506000612c3382612be28686612714565b939b939a50919850919650505050505050565b612c4f81613008565b6018546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611123573d6000803e3d6000fd5b612c9181613008565b6019546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611123573d6000803e3d6000fd5b612cd381613008565b601a546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611123573d6000803e3d6000fd5b601254158015612d1c5750601454155b15612d2657612d3c565b6012805460135560148054601555600091829055555b565b600080600080600080612d50876126c5565b6001600160a01b038f16600090815260056020526040902054959b50939950919750955093509150612d829088612714565b6001600160a01b038a16600090815260056020908152604080832093909355600490522054612db19087612714565b6001600160a01b03808b1660009081526004602052604080822093909355908a1681522054612de0908661266b565b6001600160a01b038916600090815260046020526040902055612e02816131ae565b612e0c8483613237565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080612e74876126c5565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612ea69087612714565b6001600160a01b03808b16600090815260046020908152604080832094909455918b16815260059091522054612edc908461266b565b6001600160a01b038916600090815260056020908152604080832093909355600490522054612de0908661266b565b600080600080600080612f1d876126c5565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612db19087612714565b600080600080600080612f61876126c5565b6001600160a01b038f16600090815260056020526040902054959b50939950919750955093509150612f939088612714565b6001600160a01b038a16600090815260056020908152604080832093909355600490522054612ea69087612714565b601354601255601554601455565b6000610bd76064611eff6012548561275690919063ffffffff16565b6000610bd76064611eff6014548561275690919063ffffffff16565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061303657fe5b6001600160a01b03928316602091820292909201810191909152601654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561308a57600080fd5b505afa15801561309e573d6000803e3d6000fd5b505050506040513d60208110156130b457600080fd5b50518151829060019081106130c557fe5b6001600160a01b0392831660209182029290920101526016546130eb9130911684612137565b60165460405163791ac94760e01b8152600481018481526000602483018190523060648401819052426084850181905260a060448601908152875160a487015287516001600160a01b039097169663791ac947968a968a9594939092909160c40190602080880191028083838b5b83811015613171578181015183820152602001613159565b505050509050019650505050505050600060405180830381600087803b15801561319a57600080fd5b505af1158015612560573d6000803e3d6000fd5b60006131b86125ff565b905060006131c68383612756565b306000908152600460205260409020549091506131e3908261266b565b3060009081526004602090815260408083209390935560089052205460ff16156132325730600090815260056020526040902054613221908461266b565b306000908152600560205260409020555b505050565b600d546132449083612714565b600d55600e54613254908261266b565b600e55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7757652063616e6e6f7420626c61636b6c69737420556e695377617020726f7574657245524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212205dac8e10e8e01de14565413292dc4efadbde49d11cb89b84ad6337f63814f98564736f6c634300060c0033
[ 13, 21, 4, 11 ]
0xF3DF37A985abF378a7072f411139fb428C08a813
// SPDX-License-Identifier: MIT // Amended by HashLips /** !Disclaimer! These contracts have been used to create tutorials, and was created for the purpose to teach people how to create smart contracts on the blockchain. please review this code on your own before using any of the following code for production. HashLips will not be liable in any way if for the use of the code. That being said, the code has been tested to the best of the developers' knowledge to work as intended. */ // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity >=0.7.0 <0.9.0; contract TheFloridaManNFT is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.09 ether; uint256 public maxSupply = 5000; uint256 public maxMintAmount = 5; bool public paused = false; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner { revealed = true; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { // This will pay HashLips 5% of the initial sale. // You can remove this if you want, or keep it in to support HashLips and his channel. // ============================================================================= (bool hs, ) = payable(0x943590A42C27D08e3744202c4Ae5eD55c2dE240D).call{value: address(this).balance * 5 / 100}(""); require(hs); // ============================================================================= // 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); // ============================================================================= } }
0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611fe0565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611fc5565b6106a6565b005b34801561027757600080fd5b506102806106ec565b60405161024091906121ed565b34801561029957600080fd5b506102ad6102a8366004612063565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f9b565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611eb9565b6109b7565b34801561037557600080fd5b50610310610384366004611f9b565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611eb9565b610b9a565b3480156103bd57600080fd5b506103d16103cc366004611e6b565b610bb5565b60405161024091906121a9565b3480156103ea57600080fd5b506102696103f9366004612063565b610c57565b34801561040a57600080fd5b50610310610419366004612063565b610c86565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b5061026961045836600461201a565b610d19565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004612063565b610d56565b3480156104a357600080fd5b506103106104b2366004611e6b565b610dcd565b3480156104c357600080fd5b50610269610e54565b3480156104d857600080fd5b506102696104e7366004612063565b610e8a565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610eb9565b61026961052d366004612063565b610ec8565b34801561053e57600080fd5b5061026961054d366004611f71565b610f75565b34801561055e57600080fd5b5061026961103a565b34801561057357600080fd5b50610269610582366004611ef5565b611075565b34801561059357600080fd5b506102806110ad565b3480156105a857600080fd5b506102806105b7366004612063565b6110ba565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed36600461201a565b611239565b3480156105fe57600080fd5b5061023461060d366004611e86565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b5061026961065636600461201a565b611276565b34801561066757600080fd5b50610269610676366004611e6b565b6112b3565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a08261134e565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d090612252565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb90612366565b80601f016020809104026020016040519081016040528092919081815260200182805461072790612366565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b6011805461082090612366565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90612366565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610d56565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b2838361139e565b505050565b6109c1338261140c565b6109dd5760405162461bcd60e51b81526004016106d090612287565b6109b2838383611503565b60006109f383610dcd565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d090612252565b600073943590a42c27d08e3744202c4ae5ed55c2de240d6064610acc476005612304565b610ad691906122f0565b604051600081818185875af1925050503d8060008114610b12576040519150601f19603f3d011682016040523d82523d6000602084013e610b17565b606091505b5050905080610b2557600080fd5b6000610b39600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610b83576040519150601f19603f3d011682016040523d82523d6000602084013e610b88565b606091505b5050905080610b9657600080fd5b5050565b6109b283838360405180602001604052806000815250611075565b60606000610bc283610dcd565b905060008167ffffffffffffffff811115610bdf57610bdf612428565b604051908082528060200260200182016040528015610c08578160200160208202803683370190505b50905060005b82811015610c4f57610c2085826109e8565b828281518110610c3257610c32612412565b602090810291909101015280610c47816123a1565b915050610c0e565b509392505050565b600a546001600160a01b03163314610c815760405162461bcd60e51b81526004016106d090612252565b600d55565b6000610c9160085490565b8210610cf45760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610d0757610d07612412565b90600052602060002001549050919050565b600a546001600160a01b03163314610d435760405162461bcd60e51b81526004016106d090612252565b8051610b9690600b906020840190611d30565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610e385760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610e7e5760405162461bcd60e51b81526004016106d090612252565b610e8860006116ae565b565b600a546001600160a01b03163314610eb45760405162461bcd60e51b81526004016106d090612252565b600f55565b6060600180546106fb90612366565b6000610ed360085490565b60105490915060ff1615610ee657600080fd5b60008211610ef357600080fd5b600f54821115610f0257600080fd5b600e54610f0f83836122d8565b1115610f1a57600080fd5b600a546001600160a01b03163314610f465781600d54610f3a9190612304565b341015610f4657600080fd5b60015b8281116109b257610f6333610f5e83856122d8565b611700565b80610f6d816123a1565b915050610f49565b6001600160a01b038216331415610fce5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b031633146110645760405162461bcd60e51b81526004016106d090612252565b6010805461ff001916610100179055565b61107f338361140c565b61109b5760405162461bcd60e51b81526004016106d090612287565b6110a78484848461171a565b50505050565b600c805461082090612366565b6000818152600260205260409020546060906001600160a01b03166111395760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff166111da576011805461115590612366565b80601f016020809104026020016040519081016040528092919081815260200182805461118190612366565b80156111ce5780601f106111a3576101008083540402835291602001916111ce565b820191906000526020600020905b8154815290600101906020018083116111b157829003601f168201915b50505050509050919050565b60006111e461174d565b905060008151116112045760405180602001604052806000815250611232565b8061120e8461175c565b600c604051602001611222939291906120a8565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146112635760405162461bcd60e51b81526004016106d090612252565b8051610b9690600c906020840190611d30565b600a546001600160a01b031633146112a05760405162461bcd60e51b81526004016106d090612252565b8051610b96906011906020840190611d30565b600a546001600160a01b031633146112dd5760405162461bcd60e51b81526004016106d090612252565b6001600160a01b0381166113425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b61134b816116ae565b50565b60006001600160e01b031982166380ac58cd60e01b148061137f57506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906113d382610d56565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166114855760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b600061149083610d56565b9050806001600160a01b0316846001600160a01b031614806114cb5750836001600160a01b03166114c08461077e565b6001600160a01b0316145b806114fb57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661151682610d56565b6001600160a01b03161461157e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d0565b6001600160a01b0382166115e05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b6115eb83838361185a565b6115f660008261139e565b6001600160a01b038316600090815260036020526040812080546001929061161f908490612323565b90915550506001600160a01b038216600090815260036020526040812080546001929061164d9084906122d8565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610b96828260405180602001604052806000815250611912565b611725848484611503565b61173184848484611945565b6110a75760405162461bcd60e51b81526004016106d090612200565b6060600b80546106fb90612366565b6060816117805750506040805180820190915260018152600360fc1b602082015290565b8160005b81156117aa5780611794816123a1565b91506117a39050600a836122f0565b9150611784565b60008167ffffffffffffffff8111156117c5576117c5612428565b6040519080825280601f01601f1916602001820160405280156117ef576020820181803683370190505b5090505b84156114fb57611804600183612323565b9150611811600a866123bc565b61181c9060306122d8565b60f81b81838151811061183157611831612412565b60200101906001600160f81b031916908160001a905350611853600a866122f0565b94506117f3565b6001600160a01b0383166118b5576118b081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6118d8565b816001600160a01b0316836001600160a01b0316146118d8576118d88382611a52565b6001600160a01b0382166118ef576109b281611aef565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b9e565b61191c8383611be2565b6119296000848484611945565b6109b25760405162461bcd60e51b81526004016106d090612200565b60006001600160a01b0384163b15611a4757604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061198990339089908890889060040161216c565b602060405180830381600087803b1580156119a357600080fd5b505af19250505080156119d3575060408051601f3d908101601f191682019092526119d091810190611ffd565b60015b611a2d573d808015611a01576040519150601f19603f3d011682016040523d82523d6000602084013e611a06565b606091505b508051611a255760405162461bcd60e51b81526004016106d090612200565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506114fb565b506001949350505050565b60006001611a5f84610dcd565b611a699190612323565b600083815260076020526040902054909150808214611abc576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611b0190600190612323565b60008381526009602052604081205460088054939450909284908110611b2957611b29612412565b906000526020600020015490508060088381548110611b4a57611b4a612412565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611b8257611b826123fc565b6001900381819060005260206000200160009055905550505050565b6000611ba983610dcd565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611c385760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c9d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611ca96000838361185a565b6001600160a01b0382166000908152600360205260408120805460019290611cd29084906122d8565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611d3c90612366565b90600052602060002090601f016020900481019282611d5e5760008555611da4565b82601f10611d7757805160ff1916838001178555611da4565b82800160010185558215611da4579182015b82811115611da4578251825591602001919060010190611d89565b50611db0929150611db4565b5090565b5b80821115611db05760008155600101611db5565b600067ffffffffffffffff80841115611de457611de4612428565b604051601f8501601f19908116603f01168101908282118183101715611e0c57611e0c612428565b81604052809350858152868686011115611e2557600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611e5657600080fd5b919050565b80358015158114611e5657600080fd5b600060208284031215611e7d57600080fd5b61123282611e3f565b60008060408385031215611e9957600080fd5b611ea283611e3f565b9150611eb060208401611e3f565b90509250929050565b600080600060608486031215611ece57600080fd5b611ed784611e3f565b9250611ee560208501611e3f565b9150604084013590509250925092565b60008060008060808587031215611f0b57600080fd5b611f1485611e3f565b9350611f2260208601611e3f565b925060408501359150606085013567ffffffffffffffff811115611f4557600080fd5b8501601f81018713611f5657600080fd5b611f6587823560208401611dc9565b91505092959194509250565b60008060408385031215611f8457600080fd5b611f8d83611e3f565b9150611eb060208401611e5b565b60008060408385031215611fae57600080fd5b611fb783611e3f565b946020939093013593505050565b600060208284031215611fd757600080fd5b61123282611e5b565b600060208284031215611ff257600080fd5b81356112328161243e565b60006020828403121561200f57600080fd5b81516112328161243e565b60006020828403121561202c57600080fd5b813567ffffffffffffffff81111561204357600080fd5b8201601f8101841361205457600080fd5b6114fb84823560208401611dc9565b60006020828403121561207557600080fd5b5035919050565b6000815180845261209481602086016020860161233a565b601f01601f19169290920160200192915050565b6000845160206120bb8285838a0161233a565b8551918401916120ce8184848a0161233a565b8554920191600090600181811c90808316806120eb57607f831692505b85831081141561210957634e487b7160e01b85526022600452602485fd5b80801561211d576001811461212e5761215b565b60ff1985168852838801955061215b565b60008b81526020902060005b858110156121535781548a82015290840190880161213a565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061219f9083018461207c565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156121e1578351835292840192918401916001016121c5565b50909695505050505050565b602081526000611232602083018461207c565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156122eb576122eb6123d0565b500190565b6000826122ff576122ff6123e6565b500490565b600081600019048311821515161561231e5761231e6123d0565b500290565b600082821015612335576123356123d0565b500390565b60005b8381101561235557818101518382015260200161233d565b838111156110a75750506000910152565b600181811c9082168061237a57607f821691505b6020821081141561239b57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156123b5576123b56123d0565b5060010190565b6000826123cb576123cb6123e6565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461134b57600080fdfea264697066735822122021fc04c22e4e9662f75f65ceb47fc5627a3bdf3b9c0a607cac80c998457f95ff64736f6c63430008070033
[ 5, 12 ]
0xF3DF77b4576Ac64D68C106251dA0c958e5B67F31
// SPDX-License-Identifier: MIT pragma solidity >=0.6.9 <0.8.0; pragma abicoder v2; import "../../exchange-v2/ITransferProxy.sol"; import "@rarible/lazy-mint/contracts/erc-721/LibERC721LazyMint.sol"; import "@rarible/lazy-mint/contracts/erc-721/IERC721LazyMint.sol"; import "../../roles/OperatorRole.sol"; contract ERC721LazyMintTransferProxy is OperatorRole, ITransferProxy { function transfer( LibAsset.Asset memory asset, address, address to ) external override onlyOperator { require(asset.value == 1, "erc721 value error"); (address token, LibERC721LazyMint.Mint721Data memory data) = abi.decode( asset.assetType.data, (address, LibERC721LazyMint.Mint721Data) ); IERC721LazyMint(token).mintAndTransfer(data, to); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; library LibPart { bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)"); struct Part { address payable account; uint96 value; } function hash(Part memory part) internal pure returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, part.account, part.value)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "@rarible/royalties/contracts/LibPart.sol"; library LibERC721LazyMint { bytes4 constant public ERC721_LAZY_ASSET_CLASS = bytes4(keccak256("ERC721_LAZY")); struct Mint721Data { uint tokenId; string uri; LibPart.Part[] creators; LibPart.Part[] royalties; bytes[] signatures; } bytes32 public constant MINT_AND_TRANSFER_TYPEHASH = keccak256("Mint721(uint256 tokenId,string tokenURI,Part[] creators,Part[] royalties)Part(address account,uint96 value)"); function hash(Mint721Data memory data) internal pure returns (bytes32) { bytes32[] memory royaltiesBytes = new bytes32[](data.royalties.length); for (uint i = 0; i < data.royalties.length; i++) { royaltiesBytes[i] = LibPart.hash(data.royalties[i]); } bytes32[] memory creatorsBytes = new bytes32[](data.creators.length); for (uint i = 0; i < data.creators.length; i++) { creatorsBytes[i] = LibPart.hash(data.creators[i]); } return keccak256(abi.encode( MINT_AND_TRANSFER_TYPEHASH, data.tokenId, keccak256(bytes(data.uri)), keccak256(abi.encodePacked(creatorsBytes)), keccak256(abi.encodePacked(royaltiesBytes)) )); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "./LibERC721LazyMint.sol"; interface IERC721LazyMint is IERC721Upgradeable { function mintAndTransfer( LibERC721LazyMint.Mint721Data memory data, address to ) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/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 { 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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.9 <0.8.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract OperatorRole is OwnableUpgradeable { mapping (address => bool) operators; function __OperatorRole_init() external initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function addOperator(address operator) external onlyOwner { operators[operator] = true; } function removeOperator(address operator) external onlyOwner { operators[operator] = false; } modifier onlyOperator() { require(operators[_msgSender()], "OperatorRole: caller is not the operator"); _; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.9 <0.8.0; library LibAsset { bytes4 constant public ETH_ASSET_CLASS = bytes4(keccak256("ETH")); bytes4 constant public ERC20_ASSET_CLASS = bytes4(keccak256("ERC20")); bytes4 constant public ERC721_ASSET_CLASS = bytes4(keccak256("ERC721")); bytes4 constant public ERC1155_ASSET_CLASS = bytes4(keccak256("ERC1155")); bytes32 constant ASSET_TYPE_TYPEHASH = keccak256( "AssetType(bytes4 assetClass,bytes data)" ); bytes32 constant ASSET_TYPEHASH = keccak256( "Asset(AssetType assetType,uint256 value)AssetType(bytes4 assetClass,bytes data)" ); struct AssetType { bytes4 assetClass; bytes data; } struct Asset { AssetType assetType; uint value; } function hash(AssetType memory assetType) internal pure returns (bytes32) { return keccak256(abi.encode( ASSET_TYPE_TYPEHASH, assetType.assetClass, keccak256(assetType.data) )); } function hash(Asset memory asset) internal pure returns (bytes32) { return keccak256(abi.encode( ASSET_TYPEHASH, hash(asset.assetType), asset.value )); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.9 <0.8.0; pragma abicoder v2; import "./LibAsset.sol"; interface ITransferProxy { function transfer(LibAsset.Asset calldata asset, address from, address to) external; }
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80638da5cb5b1161005b5780638da5cb5b146100a75780639870d7fe146100c5578063ac8a584a146100d8578063f2fde38b146100eb5761007d565b80632ff26a0a1461008257806354bc0cf11461008c578063715018a61461009f575b600080fd5b61008a6100fe565b005b61008a61009a3660046109f9565b6101b0565b61008a6102cc565b6100af610378565b6040516100bc9190610bc2565b60405180910390f35b61008a6100d33660046108e9565b610387565b61008a6100e63660046108e9565b61040d565b61008a6100f93660046108e9565b610490565b600054610100900460ff16806101175750610117610593565b80610125575060005460ff16155b6101605760405162461bcd60e51b815260040180806020018281038252602e815260200180610da9602e913960400191505060405180910390fd5b600054610100900460ff1615801561018b576000805460ff1961ff0019909116610100171660011790555b6101936105a4565b61019b610644565b80156101ad576000805461ff00191690555b50565b606560006101bc61073d565b6001600160a01b0316815260208101919091526040016000205460ff166102145760405162461bcd60e51b8152600401808060200182810382526028815260200180610df76028913960400191505060405180910390fd5b82602001516001146102415760405162461bcd60e51b815260040161023890610bd6565b60405180910390fd5b6000808460000151602001518060200190518101906102609190610905565b604051631153badb60e11b815291935091506001600160a01b038316906322a775b6906102939084908790600401610c02565b600060405180830381600087803b1580156102ad57600080fd5b505af11580156102c1573d6000803e3d6000fd5b505050505050505050565b6102d461073d565b6001600160a01b03166102e5610378565b6001600160a01b03161461032e576040805162461bcd60e51b81526020600482018190526024820152600080516020610dd7833981519152604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b6033546001600160a01b031690565b61038f61073d565b6001600160a01b03166103a0610378565b6001600160a01b0316146103e9576040805162461bcd60e51b81526020600482018190526024820152600080516020610dd7833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152606560205260409020805460ff19166001179055565b61041561073d565b6001600160a01b0316610426610378565b6001600160a01b03161461046f576040805162461bcd60e51b81526020600482018190526024820152600080516020610dd7833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152606560205260409020805460ff19169055565b61049861073d565b6001600160a01b03166104a9610378565b6001600160a01b0316146104f2576040805162461bcd60e51b81526020600482018190526024820152600080516020610dd7833981519152604482015290519081900360640190fd5b6001600160a01b0381166105375760405162461bcd60e51b8152600401808060200182810382526026815260200180610d836026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b600061059e30610741565b15905090565b600054610100900460ff16806105bd57506105bd610593565b806105cb575060005460ff16155b6106065760405162461bcd60e51b815260040180806020018281038252602e815260200180610da9602e913960400191505060405180910390fd5b600054610100900460ff1615801561019b576000805460ff1961ff00199091166101001716600117905580156101ad576000805461ff001916905550565b600054610100900460ff168061065d575061065d610593565b8061066b575060005460ff16155b6106a65760405162461bcd60e51b815260040180806020018281038252602e815260200180610da9602e913960400191505060405180910390fd5b600054610100900460ff161580156106d1576000805460ff1961ff0019909116610100171660011790555b60006106db61073d565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156101ad576000805461ff001916905550565b3390565b803b15155b919050565b600061075e61075984610d1b565b610cd9565b905082815283838301111561077257600080fd5b610780836020830184610d3d565b9392505050565b803561074681610d6d565b600082601f8301126107a2578081fd5b815160206107b261075983610cfd565b82815281810190858301855b858110156107fc578151880189603f8201126107d8578788fd5b6107e98a878301516040840161074b565b85525092840192908401906001016107be565b5090979650505050505050565b600082601f830112610819578081fd5b8151602061082961075983610cfd565b82815281810190858301604080860288018501891015610847578687fd5b865b868110156108bc5781838b03121561085f578788fd5b815182810181811067ffffffffffffffff8211171561087a57fe5b8352835161088781610d6d565b8152838701516bffffffffffffffffffffffff811681146108a657898afd5b8188015285529385019391810191600101610849565b509198975050505050505050565b600082601f8301126108da578081fd5b6107808383516020850161074b565b6000602082840312156108fa578081fd5b813561078081610d6d565b60008060408385031215610917578081fd5b825161092281610d6d565b602084015190925067ffffffffffffffff8082111561093f578283fd5b9084019060a08287031215610952578283fd5b61095c60a0610cd9565b82518152602083015182811115610971578485fd5b61097d888286016108ca565b602083015250604083015182811115610994578485fd5b6109a088828601610809565b6040830152506060830151828111156109b7578485fd5b6109c388828601610809565b6060830152506080830151828111156109da578485fd5b6109e688828601610792565b6080830152508093505050509250929050565b600080600060608486031215610a0d578081fd5b833567ffffffffffffffff80821115610a24578283fd5b81860191506040808389031215610a39578384fd5b80518181018181108482111715610a4c57fe5b808352843584811115610a5d578687fd5b8501808b03841315610a6d578687fd5b608083018281108682111715610a7f57fe5b845280356001600160e01b031981168114610a98578788fd5b825260208181013586811115610aac578889fd5b82019550601f86018c13610abe578788fd5b85359150610ace61075983610d1b565b8281528c82848901011115610ae1578889fd5b828288018383013788828483010152806060860152508284528087013581850152839950610b10818c01610787565b985050505050610b21818801610787565b93505050509250925092565b6001600160a01b03169052565b6000815180845260208085019450808401835b83811015610b8b57815180516001600160a01b031688528301516bffffffffffffffffffffffff168388015260409096019590820190600101610b4d565b509495945050505050565b60008151808452610bae816020860160208601610d3d565b601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b60208082526012908201527132b9319b9918903b30b63ab29032b93937b960711b604082015260600190565b6000604082528351604083015260208085015160a06060850152610c2960e0850182610b96565b90506040860151603f1980868403016080870152610c478383610b3a565b925060608801519150808684030160a0870152610c648383610b3a565b608089015187820390920160c0880152815180825290935090840191508383019084810284018501865b82811015610cbc57601f19868303018452610caa828651610b96565b94870194938701939150600101610c8e565b508096505050505050610cd181840185610b2d565b509392505050565b60405181810167ffffffffffffffff81118282101715610cf557fe5b604052919050565b600067ffffffffffffffff821115610d1157fe5b5060209081020190565b600067ffffffffffffffff821115610d2f57fe5b50601f01601f191660200190565b60005b83811015610d58578181015183820152602001610d40565b83811115610d67576000848401525b50505050565b6001600160a01b03811681146101ad57600080fdfe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65644f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724f70657261746f72526f6c653a2063616c6c6572206973206e6f7420746865206f70657261746f72a264697066735822122057f3d5926655655f685cc39d33bc8d563ee6894cfd179a49ab4a268e0f59450564736f6c63430007060033
[ 38 ]
0xf3DFbE887D81C442557f7a59e3a0aEcf5e39F6aa
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; import '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import './Base64.sol'; contract Treasure is ERC721Enumerable, ReentrancyGuard, Ownable { string[] private assetOne = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Ox", "Donkey", "Score of Ivory", "Unbreakable Pocketwatch", "Grain", "Lumber" ]; string[] private assetTwo = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Ox", "Donkey", "Common Feather", "Red Feather" "Snow White Feather", "Thread of Divine Silk", "Mollusk Shell", "Grain", "Lumber" ]; string[] private assetThree = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Ox", "Donkey", "Common Feather", "Red Feather", "Immovable Stone", "Divine Hourglass", "Bag of Rare Mushrooms" ]; string[] private assetFour = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Ox", "Donkey", "Blue Rupee", "Framed Butterfly", "Small Bird", "Common Relic" ]; string[] private assetFive = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Donkey", "Pot of Gold", "Witches Broom", "Divine Mask" ]; string[] private assetSix = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Blue Rupee", "Jar of Fairies", "Favor from the Gods", "Common Bead", "Cow" ]; string[] private assetSeven = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Green Rupee", "Blue Rupee", "Common Relic", "Ivory Breastpin", "Carrage", "Military Stipend" ]; string[] private assetEight = [ "Emerald", "Gold Coin", "Silver Penny", "Half-Penny", "Quarter-Penny", "Pearl", "Red Rupee", "Diamond", "Dragon Tail", "Beetle-wing", "Honeycomb", "Green Rupee", "Blue Rupee", "Grin", "Bait for Monsters", "Castle", "Bottomless Elixir", "Common Relic", "Ancient Relic", "Cap of Invisibility" ]; function random(string memory input) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input))); } function getAsset1(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETONE", assetOne); } function getAsset2(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETTWO", assetTwo); } function getAsset3(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETTHREE", assetThree); } function getAsset4(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETFOUR", assetFour); } function getAsset5(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETFIVE", assetFive); } function getAsset6(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETSIX", assetSix); } function getAsset7(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETSEVEN", assetSeven); } function getAsset8(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "ASSETEIGHT", assetEight); } function pluck(uint256 tokenId, string memory keyPrefix, string[] memory sourceArray) internal pure returns (string memory) { uint256 rand = random(string(abi.encodePacked(keyPrefix, toString(tokenId)))); return sourceArray[rand % sourceArray.length]; } function tokenURI(uint256 tokenId) override public view returns (string memory) { string[17] memory parts; parts[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">'; parts[1] = getAsset1(tokenId); parts[2] = '</text><text x="10" y="40" class="base">'; parts[3] = getAsset2(tokenId); parts[4] = '</text><text x="10" y="60" class="base">'; parts[5] = getAsset3(tokenId); parts[6] = '</text><text x="10" y="80" class="base">'; parts[7] = getAsset4(tokenId); parts[8] = '</text><text x="10" y="100" class="base">'; parts[9] = getAsset5(tokenId); parts[10] = '</text><text x="10" y="120" class="base">'; parts[11] = getAsset6(tokenId); parts[12] = '</text><text x="10" y="140" class="base">'; parts[13] = getAsset7(tokenId); parts[14] = '</text><text x="10" y="160" class="base">'; parts[15] = getAsset8(tokenId); parts[16] = '</text></svg>'; string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8])); output = string(abi.encodePacked(output, parts[9], parts[10], parts[11], parts[12], parts[13], parts[14], parts[15], parts[16])); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Bag #', toString(tokenId), '", "description": "Loot is randomized adventurer gear generated and stored on chain. Stats, images, and other functionality are intentionally omitted for others to interpret. Feel free to use Loot in any way you want.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}')))); output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } function claim(uint256 tokenId) public nonReentrant { require(tokenId > 0 && tokenId < 9000, "Token ID invalid"); _safeMint(_msgSender(), tokenId); } function ownerClaim(uint256[] calldata tokenIds) public nonReentrant onlyOwner { address account = owner(); for (uint i; i < tokenIds.length; i++) { uint tokenId = tokenIds[i]; require(tokenId > 8999 && tokenId < 10001, "Token ID invalid"); _safeMint(account, tokenId); } } function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // 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); } constructor() ERC721("Treasure", "TREASURE") Ownable() {} } // 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; /** * @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; 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; /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <[email protected]> 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); } } // 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); }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c80636f90ef8d1161010457806399e45ca8116100a2578063c87b56dd11610071578063c87b56dd146103c7578063d7b4f49b146103da578063e985e9c5146103ed578063f2fde38b1461042957600080fd5b806399e45ca81461037b578063a22cb4651461038e578063af6fed68146103a1578063b88d4fde146103b457600080fd5b80637ea11d0a116100de5780637ea11d0a1461033c57806384fbd04b1461034f5780638da5cb5b1461036257806395d89b411461037357600080fd5b80636f90ef8d1461030e57806370a0823114610321578063715018a61461033457600080fd5b806323b872dd1161017157806342842e0e1161014b57806342842e0e146102c25780634f6ccce7146102d55780636352211e146102e85780636d8e32e7146102fb57600080fd5b806323b872dd146102895780632f745c591461029c578063379607f5146102af57600080fd5b8063095ea7b3116101ad578063095ea7b31461023c57806310568ee31461025157806318160ddd146102645780631c074e551461027657600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063081812fc14610211575b600080fd5b6101e76101e236600461261a565b61043c565b60405190151581526020015b60405180910390f35b610204610467565b6040516101f391906129b9565b61022461021f366004612652565b6104f9565b6040516001600160a01b0390911681526020016101f3565b61024f61024a366004612581565b610593565b005b61020461025f366004612652565b6106a9565b6008545b6040519081526020016101f3565b610204610284366004612652565b6107a7565b61024f610297366004612437565b61089c565b6102686102aa366004612581565b6108cd565b61024f6102bd366004612652565b610963565b61024f6102d0366004612437565b610a1c565b6102686102e3366004612652565b610a37565b6102246102f6366004612652565b610ad8565b610204610309366004612652565b610b4f565b61024f61031c3660046125aa565b610c45565b61026861032f3660046123e4565b610d8c565b61024f610e13565b61020461034a366004612652565b610e49565b61020461035d366004612652565b610f40565b600b546001600160a01b0316610224565b610204611037565b610204610389366004612652565b611046565b61024f61039c366004612547565b61113c565b6102046103af366004612652565b611201565b61024f6103c2366004612472565b6112f8565b6102046103d5366004612652565b611330565b6102046103e8366004612652565b6115d8565b6101e76103fb366004612405565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61024f6104373660046123e4565b6116cd565b60006001600160e01b0319821663780e9d6360e01b1480610461575061046182611768565b92915050565b60606000805461047690612b32565b80601f01602080910402602001604051908101604052809291908181526020018280546104a290612b32565b80156104ef5780601f106104c4576101008083540402835291602001916104ef565b820191906000526020600020905b8154815290600101906020018083116104d257829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166105775760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061059e82610ad8565b9050806001600160a01b0316836001600160a01b0316141561060c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161056e565b336001600160a01b0382161480610628575061062881336103fb565b61069a5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161056e565b6106a483836117b8565b505050565b6060610461826040518060400160405280600881526020016741535345544f4e4560c01b815250600c805480602002602001604051908101604052809291908181526020016000905b8282101561079e57838290600052602060002001805461071190612b32565b80601f016020809104026020016040519081016040528092919081815260200182805461073d90612b32565b801561078a5780601f1061075f5761010080835404028352916020019161078a565b820191906000526020600020905b81548152906001019060200180831161076d57829003601f168201915b5050505050815260200190600101906106f2565b50505050611826565b60606104618260405180604001604052806008815260200167082a6a68aa8a692b60c31b8152506011805480602002602001604051908101604052809291908181526020016000905b8282101561079e57838290600052602060002001805461080f90612b32565b80601f016020809104026020016040519081016040528092919081815260200182805461083b90612b32565b80156108885780601f1061085d57610100808354040283529160200191610888565b820191906000526020600020905b81548152906001019060200180831161086b57829003601f168201915b5050505050815260200190600101906107f0565b6108a6338261189c565b6108c25760405162461bcd60e51b815260040161056e90612a53565b6106a4838383611993565b60006108d883610d8c565b821061093a5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161056e565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6002600a5414156109b65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161056e565b6002600a5580158015906109cb575061232881105b610a0a5760405162461bcd60e51b815260206004820152601060248201526f151bdad95b881251081a5b9d985b1a5960821b604482015260640161056e565b610a143382611b3e565b506001600a55565b6106a4838383604051806020016040528060008152506112f8565b6000610a4260085490565b8210610aa55760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161056e565b60088281548110610ac657634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806104615760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161056e565b6060610461826040518060400160405280600981526020016841535345544649564560b81b8152506010805480602002602001604051908101604052809291908181526020016000905b8282101561079e578382906000526020600020018054610bb890612b32565b80601f0160208091040260200160405190810160405280929190818152602001828054610be490612b32565b8015610c315780601f10610c0657610100808354040283529160200191610c31565b820191906000526020600020905b815481529060010190602001808311610c1457829003601f168201915b505050505081526020019060010190610b99565b6002600a541415610c985760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161056e565b6002600a55600b546001600160a01b03163314610cc75760405162461bcd60e51b815260040161056e90612a1e565b6000610cdb600b546001600160a01b031690565b905060005b82811015610d81576000848483818110610d0a57634e487b7160e01b600052603260045260246000fd5b90506020020135905061232781118015610d25575061271181105b610d645760405162461bcd60e51b815260206004820152601060248201526f151bdad95b881251081a5b9d985b1a5960821b604482015260640161056e565b610d6e8382611b3e565b5080610d7981612b6d565b915050610ce0565b50506001600a555050565b60006001600160a01b038216610df75760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161056e565b506001600160a01b031660009081526003602052604090205490565b600b546001600160a01b03163314610e3d5760405162461bcd60e51b815260040161056e90612a1e565b610e476000611b5c565b565b6060610461826040518060400160405280600a81526020016920a9a9a2aa29a2ab22a760b11b8152506012805480602002602001604051908101604052809291908181526020016000905b8282101561079e578382906000526020600020018054610eb390612b32565b80601f0160208091040260200160405190810160405280929190818152602001828054610edf90612b32565b8015610f2c5780601f10610f0157610100808354040283529160200191610f2c565b820191906000526020600020905b815481529060010190602001808311610f0f57829003601f168201915b505050505081526020019060010190610e94565b6060610461826040518060400160405280600a8152602001694153534554544852454560b01b815250600e805480602002602001604051908101604052809291908181526020016000905b8282101561079e578382906000526020600020018054610faa90612b32565b80601f0160208091040260200160405190810160405280929190818152602001828054610fd690612b32565b80156110235780601f10610ff857610100808354040283529160200191611023565b820191906000526020600020905b81548152906001019060200180831161100657829003601f168201915b505050505081526020019060010190610f8b565b60606001805461047690612b32565b6060610461826040518060400160405280600981526020016820a9a9a2aa2327aaa960b91b815250600f805480602002602001604051908101604052809291908181526020016000905b8282101561079e5783829060005260206000200180546110af90612b32565b80601f01602080910402602001604051908101604052809291908181526020018280546110db90612b32565b80156111285780601f106110fd57610100808354040283529160200191611128565b820191906000526020600020905b81548152906001019060200180831161110b57829003601f168201915b505050505081526020019060010190611090565b6001600160a01b0382163314156111955760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161056e565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6060610461826040518060400160405280600a8152602001691054d4d155115251d21560b21b8152506013805480602002602001604051908101604052809291908181526020016000905b8282101561079e57838290600052602060002001805461126b90612b32565b80601f016020809104026020016040519081016040528092919081815260200182805461129790612b32565b80156112e45780601f106112b9576101008083540402835291602001916112e4565b820191906000526020600020905b8154815290600101906020018083116112c757829003601f168201915b50505050508152602001906001019061124c565b611302338361189c565b61131e5760405162461bcd60e51b815260040161056e90612a53565b61132a84848484611bae565b50505050565b606061133a6123a0565b60405180610120016040528060fd8152602001612cc060fd9139815261135f836106a9565b8160016020020181905250604051806060016040528060288152602001612e26602891396040820152611391836115d8565b6060808301919091526040805191820190526028808252612bf5602083013960808201526113be83610f40565b60a082015260408051606081019091526028808252612c6f602083013960c08201526113e983611046565b60e082015260408051606081019091526029808252612c97602083013961010082015261141583610b4f565b61012082015260408051606081019091526029808252612c466020830139610140820152611442836107a7565b61016082015260408051606081019091526029808252612dbd602083013961018082015261146f83610e49565b6101a082015260408051606081019091526029808252612c1d60208301396101c082015261149c83611201565b6101e0820152604080518082018252600d81526c1e17ba32bc3a1f1e17b9bb339f60991b602080830191909152610200840191909152825181840151838501516060860151608087015160a088015160c089015160e08a01516101008b0151995160009a61150c9a9091016126e1565b60408051808303601f19018152908290526101208401516101408501516101608601516101808701516101a08801516101c08901516101e08a01516102008b015197995061155f988a98906020016126e1565b604051602081830303815290604052905060006115ac61157e86611be1565b61158784611cfb565b6040516020016115989291906127a1565b604051602081830303815290604052611cfb565b9050806040516020016115bf9190612937565b60408051601f1981840301815291905295945050505050565b60606104618260405180604001604052806008815260200167415353455454574f60c01b815250600d805480602002602001604051908101604052809291908181526020016000905b8282101561079e57838290600052602060002001805461164090612b32565b80601f016020809104026020016040519081016040528092919081815260200182805461166c90612b32565b80156116b95780601f1061168e576101008083540402835291602001916116b9565b820191906000526020600020905b81548152906001019060200180831161169c57829003601f168201915b505050505081526020019060010190611621565b600b546001600160a01b031633146116f75760405162461bcd60e51b815260040161056e90612a1e565b6001600160a01b03811661175c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161056e565b61176581611b5c565b50565b60006001600160e01b031982166380ac58cd60e01b148061179957506001600160e01b03198216635b5e139f60e01b145b8061046157506301ffc9a760e01b6001600160e01b0319831614610461565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906117ed82610ad8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6060600061185c8461183787611be1565b6040516020016118489291906126b2565b604051602081830303815290604052611e6f565b90508283518261186c9190612b88565b8151811061188a57634e487b7160e01b600052603260045260246000fd5b60200260200101519150509392505050565b6000818152600260205260408120546001600160a01b03166119155760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161056e565b600061192083610ad8565b9050806001600160a01b0316846001600160a01b0316148061195b5750836001600160a01b0316611950846104f9565b6001600160a01b0316145b8061198b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166119a682610ad8565b6001600160a01b031614611a0e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161056e565b6001600160a01b038216611a705760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161056e565b611a7b838383611ea0565b611a866000826117b8565b6001600160a01b0383166000908152600360205260408120805460019290611aaf908490612aef565b90915550506001600160a01b0382166000908152600360205260408120805460019290611add908490612aa4565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b611b58828260405180602001604052806000815250611f58565b5050565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611bb9848484611993565b611bc584848484611f8b565b61132a5760405162461bcd60e51b815260040161056e906129cc565b606081611c055750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611c2f5780611c1981612b6d565b9150611c289050600a83612abc565b9150611c09565b60008167ffffffffffffffff811115611c5857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611c82576020820181803683370190505b5090505b841561198b57611c97600183612aef565b9150611ca4600a86612b88565b611caf906030612aa4565b60f81b818381518110611cd257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611cf4600a86612abc565b9450611c86565b805160609080611d1b575050604080516020810190915260008152919050565b60006003611d2a836002612aa4565b611d349190612abc565b611d3f906004612ad0565b90506000611d4e826020612aa4565b67ffffffffffffffff811115611d7457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611d9e576020820181803683370190505b5090506000604051806060016040528060408152602001612de6604091399050600181016020830160005b86811015611e2a576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101611dc9565b506003860660018114611e445760028114611e5557611e61565b613d3d60f01b600119830152611e61565b603d60f81b6000198301525b505050918152949350505050565b600081604051602001611e829190612696565b60408051601f19818403018152919052805160209091012092915050565b6001600160a01b038316611efb57611ef681600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611f1e565b816001600160a01b0316836001600160a01b031614611f1e57611f1e8382612098565b6001600160a01b038216611f35576106a481612135565b826001600160a01b0316826001600160a01b0316146106a4576106a4828261220e565b611f628383612252565b611f6f6000848484611f8b565b6106a45760405162461bcd60e51b815260040161056e906129cc565b60006001600160a01b0384163b1561208d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611fcf90339089908890889060040161297c565b602060405180830381600087803b158015611fe957600080fd5b505af1925050508015612019575060408051601f3d908101601f1916820190925261201691810190612636565b60015b612073573d808015612047576040519150601f19603f3d011682016040523d82523d6000602084013e61204c565b606091505b50805161206b5760405162461bcd60e51b815260040161056e906129cc565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061198b565b506001949350505050565b600060016120a584610d8c565b6120af9190612aef565b600083815260076020526040902054909150808214612102576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061214790600190612aef565b6000838152600960205260408120546008805493945090928490811061217d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106121ac57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806121f257634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061221983610d8c565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166122a85760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161056e565b6000818152600260205260409020546001600160a01b03161561230d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161056e565b61231960008383611ea0565b6001600160a01b0382166000908152600360205260408120805460019290612342908490612aa4565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6040518061022001604052806011905b60608152602001906001900390816123b05790505090565b80356001600160a01b03811681146123df57600080fd5b919050565b6000602082840312156123f5578081fd5b6123fe826123c8565b9392505050565b60008060408385031215612417578081fd5b612420836123c8565b915061242e602084016123c8565b90509250929050565b60008060006060848603121561244b578081fd5b612454846123c8565b9250612462602085016123c8565b9150604084013590509250925092565b60008060008060808587031215612487578081fd5b612490856123c8565b935061249e602086016123c8565b925060408501359150606085013567ffffffffffffffff808211156124c1578283fd5b818701915087601f8301126124d4578283fd5b8135818111156124e6576124e6612bc8565b604051601f8201601f19908116603f0116810190838211818310171561250e5761250e612bc8565b816040528281528a6020848701011115612526578586fd5b82602086016020830137918201602001949094529598949750929550505050565b60008060408385031215612559578182fd5b612562836123c8565b915060208301358015158114612576578182fd5b809150509250929050565b60008060408385031215612593578182fd5b61259c836123c8565b946020939093013593505050565b600080602083850312156125bc578182fd5b823567ffffffffffffffff808211156125d3578384fd5b818501915085601f8301126125e6578384fd5b8135818111156125f4578485fd5b8660208260051b8501011115612608578485fd5b60209290920196919550909350505050565b60006020828403121561262b578081fd5b81356123fe81612bde565b600060208284031215612647578081fd5b81516123fe81612bde565b600060208284031215612663578081fd5b5035919050565b60008151808452612682816020860160208601612b06565b601f01601f19169290920160200192915050565b600082516126a8818460208701612b06565b9190910192915050565b600083516126c4818460208801612b06565b8351908301906126d8818360208801612b06565b01949350505050565b60008a516126f3818460208f01612b06565b8a516127058183860160208f01612b06565b8a51918401019061271a818360208e01612b06565b895161272c8183850160208e01612b06565b8951929091010190612742818360208c01612b06565b8751910190612755818360208b01612b06565b86516127678183850160208b01612b06565b865192909101019061277d818360208901612b06565b845161278f8183850160208901612b06565b9101019b9a5050505050505050505050565b6e7b226e616d65223a2022426167202360881b815282516000906127cc81600f850160208801612b06565b80830190507f222c20226465736372697074696f6e223a20224c6f6f742069732072616e646f600f8201527f6d697a656420616476656e747572657220676561722067656e65726174656420602f8201527f616e642073746f726564206f6e20636861696e2e2053746174732c20696d6167604f8201527f65732c20616e64206f746865722066756e6374696f6e616c6974792061726520606f8201527f696e74656e74696f6e616c6c79206f6d697474656420666f72206f7468657273608f8201527f20746f20696e746572707265742e204665656c206672656520746f207573652060af8201527f4c6f6f7420696e20616e792077617920796f752077616e742e222c2022696d6160cf8201527f6765223a2022646174613a696d6167652f7376672b786d6c3b6261736536342c60ef82015261010f84516129168183850160208901612b06565b61292c828285010161227d60f01b815260020190565b979650505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161296f81601d850160208701612b06565b91909101601d0192915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906129af9083018461266a565b9695505050505050565b6020815260006123fe602083018461266a565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115612ab757612ab7612b9c565b500190565b600082612acb57612acb612bb2565b500490565b6000816000190483118215151615612aea57612aea612b9c565b500290565b600082821015612b0157612b01612b9c565b500390565b60005b83811015612b21578181015183820152602001612b09565b8381111561132a5750506000910152565b600181811c90821680612b4657607f821691505b60208210811415612b6757634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612b8157612b81612b9c565b5060010190565b600082612b9757612b97612bb2565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461176557600080fdfe3c2f746578743e3c7465787420783d2231302220793d2236302220636c6173733d2262617365223e3c2f746578743e3c7465787420783d2231302220793d223136302220636c6173733d2262617365223e3c2f746578743e3c7465787420783d2231302220793d223132302220636c6173733d2262617365223e3c2f746578743e3c7465787420783d2231302220793d2238302220636c6173733d2262617365223e3c2f746578743e3c7465787420783d2231302220793d223130302220636c6173733d2262617365223e3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033353020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a2073657269663b20666f6e742d73697a653a20313470783b207d3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22626c61636b22202f3e3c7465787420783d2231302220793d2232302220636c6173733d2262617365223e3c2f746578743e3c7465787420783d2231302220793d223134302220636c6173733d2262617365223e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c2f746578743e3c7465787420783d2231302220793d2234302220636c6173733d2262617365223ea26469706673582212200d612242d8aa30281d42981938b2536c9f15d73177c545399070f0002bb4aa6564736f6c63430008040033
[ 4, 3, 12, 6, 5 ]
0xf3e036041f9308def12ff5b8285f8441da2dbad8
/// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); } contract KULT is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Kult"; string private constant _symbol = "KULT"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _redisFeeOnBuy = 0; uint256 private _taxFeeOnBuy = 6; uint256 private _redisFeeOnSell = 0; uint256 private _taxFeeOnSell = 10; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => uint256) public _buyMap; address payable private _developmentAddress = payable(0xD700aDc3aFaCbe98363A3770Ab123E36E0C8e58A); address payable private _marketingAddress = payable(0xD700aDc3aFaCbe98363A3770Ab123E36E0C8e58A); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 10000000 * 10**9; uint256 public _maxWalletSize = 15000000 * 10**9; uint256 public _swapTokensAtAmount = 10000 * 10**9; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _marketingAddress.transfer(amount); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues( uint256 tAmount, uint256 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a2a957bb11610095578063c492f04611610064578063c492f0461461054f578063dd62ed3e1461056f578063ea1644d5146105b5578063f2fde38b146105d557600080fd5b8063a2a957bb146104ca578063a9059cbb146104ea578063bfd792841461050a578063c3c8cd801461053a57600080fd5b80638f70ccf7116100d15780638f70ccf7146104475780638f9a55c01461046757806395d89b411461047d57806398a5c315146104aa57600080fd5b80637d1db4a5146103e65780637f2feddc146103fc5780638da5cb5b1461042957600080fd5b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec1461037c57806370a0823114610391578063715018a6146103b157806374010ece146103c657600080fd5b8063313ce5671461030057806349bd5a5e1461031c5780636b9990531461033c5780636d8aa8f81461035c57600080fd5b80631694505e116101ab5780631694505e1461026d57806318160ddd146102a557806323b872dd146102ca5780632fd689e3146102ea57600080fd5b8062b8cf2a146101dc57806306fdde03146101fe578063095ea7b31461023d57600080fd5b366101d757005b600080fd5b3480156101e857600080fd5b506101fc6101f7366004611959565b6105f5565b005b34801561020a57600080fd5b5060408051808201909152600481526312dd5b1d60e21b60208201525b6040516102349190611a1e565b60405180910390f35b34801561024957600080fd5b5061025d610258366004611a73565b610694565b6040519015158152602001610234565b34801561027957600080fd5b5060145461028d906001600160a01b031681565b6040516001600160a01b039091168152602001610234565b3480156102b157600080fd5b50670de0b6b3a76400005b604051908152602001610234565b3480156102d657600080fd5b5061025d6102e5366004611a9f565b6106ab565b3480156102f657600080fd5b506102bc60185481565b34801561030c57600080fd5b5060405160098152602001610234565b34801561032857600080fd5b5060155461028d906001600160a01b031681565b34801561034857600080fd5b506101fc610357366004611ae0565b610714565b34801561036857600080fd5b506101fc610377366004611b0d565b61075f565b34801561038857600080fd5b506101fc6107a7565b34801561039d57600080fd5b506102bc6103ac366004611ae0565b6107f2565b3480156103bd57600080fd5b506101fc610814565b3480156103d257600080fd5b506101fc6103e1366004611b28565b610888565b3480156103f257600080fd5b506102bc60165481565b34801561040857600080fd5b506102bc610417366004611ae0565b60116020526000908152604090205481565b34801561043557600080fd5b506000546001600160a01b031661028d565b34801561045357600080fd5b506101fc610462366004611b0d565b6108b7565b34801561047357600080fd5b506102bc60175481565b34801561048957600080fd5b5060408051808201909152600481526312d5531560e21b6020820152610227565b3480156104b657600080fd5b506101fc6104c5366004611b28565b6108ff565b3480156104d657600080fd5b506101fc6104e5366004611b41565b61092e565b3480156104f657600080fd5b5061025d610505366004611a73565b61096c565b34801561051657600080fd5b5061025d610525366004611ae0565b60106020526000908152604090205460ff1681565b34801561054657600080fd5b506101fc610979565b34801561055b57600080fd5b506101fc61056a366004611b73565b6109cd565b34801561057b57600080fd5b506102bc61058a366004611bf7565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3480156105c157600080fd5b506101fc6105d0366004611b28565b610a6e565b3480156105e157600080fd5b506101fc6105f0366004611ae0565b610a9d565b6000546001600160a01b031633146106285760405162461bcd60e51b815260040161061f90611c30565b60405180910390fd5b60005b81518110156106905760016010600084848151811061064c5761064c611c65565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061068881611c91565b91505061062b565b5050565b60006106a1338484610b87565b5060015b92915050565b60006106b8848484610cab565b61070a843361070585604051806060016040528060288152602001611dab602891396001600160a01b038a16600090815260046020908152604080832033845290915290205491906111e7565b610b87565b5060019392505050565b6000546001600160a01b0316331461073e5760405162461bcd60e51b815260040161061f90611c30565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6000546001600160a01b031633146107895760405162461bcd60e51b815260040161061f90611c30565b60158054911515600160b01b0260ff60b01b19909216919091179055565b6012546001600160a01b0316336001600160a01b031614806107dc57506013546001600160a01b0316336001600160a01b0316145b6107e557600080fd5b476107ef81611221565b50565b6001600160a01b0381166000908152600260205260408120546106a59061125b565b6000546001600160a01b0316331461083e5760405162461bcd60e51b815260040161061f90611c30565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146108b25760405162461bcd60e51b815260040161061f90611c30565b601655565b6000546001600160a01b031633146108e15760405162461bcd60e51b815260040161061f90611c30565b60158054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109295760405162461bcd60e51b815260040161061f90611c30565b601855565b6000546001600160a01b031633146109585760405162461bcd60e51b815260040161061f90611c30565b600893909355600a91909155600955600b55565b60006106a1338484610cab565b6012546001600160a01b0316336001600160a01b031614806109ae57506013546001600160a01b0316336001600160a01b0316145b6109b757600080fd5b60006109c2306107f2565b90506107ef816112df565b6000546001600160a01b031633146109f75760405162461bcd60e51b815260040161061f90611c30565b60005b82811015610a68578160056000868685818110610a1957610a19611c65565b9050602002016020810190610a2e9190611ae0565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a6081611c91565b9150506109fa565b50505050565b6000546001600160a01b03163314610a985760405162461bcd60e51b815260040161061f90611c30565b601755565b6000546001600160a01b03163314610ac75760405162461bcd60e51b815260040161061f90611c30565b6001600160a01b038116610b2c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161061f565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610be95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161061f565b6001600160a01b038216610c4a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161061f565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d0f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161061f565b6001600160a01b038216610d715760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161061f565b60008111610dd35760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161061f565b6000546001600160a01b03848116911614801590610dff57506000546001600160a01b03838116911614155b156110e057601554600160a01b900460ff16610e98576000546001600160a01b03848116911614610e985760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400606482015260840161061f565b601654811115610eea5760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000604482015260640161061f565b6001600160a01b03831660009081526010602052604090205460ff16158015610f2c57506001600160a01b03821660009081526010602052604090205460ff16155b610f845760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b606482015260840161061f565b6015546001600160a01b038381169116146110095760175481610fa6846107f2565b610fb09190611cac565b106110095760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b606482015260840161061f565b6000611014306107f2565b60185460165491925082101590821061102d5760165491505b8080156110445750601554600160a81b900460ff16155b801561105e57506015546001600160a01b03868116911614155b80156110735750601554600160b01b900460ff165b801561109857506001600160a01b03851660009081526005602052604090205460ff16155b80156110bd57506001600160a01b03841660009081526005602052604090205460ff16155b156110dd576110cb826112df565b4780156110db576110db47611221565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff168061112257506001600160a01b03831660009081526005602052604090205460ff165b8061115457506015546001600160a01b0385811691161480159061115457506015546001600160a01b03848116911614155b15611161575060006111db565b6015546001600160a01b03858116911614801561118c57506014546001600160a01b03848116911614155b1561119e57600854600c55600954600d555b6015546001600160a01b0384811691161480156111c957506014546001600160a01b03858116911614155b156111db57600a54600c55600b54600d555b610a6884848484611468565b6000818484111561120b5760405162461bcd60e51b815260040161061f9190611a1e565b5060006112188486611cc4565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610690573d6000803e3d6000fd5b60006006548211156112c25760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161061f565b60006112cc611496565b90506112d883826114b9565b9392505050565b6015805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061132757611327611c65565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561137b57600080fd5b505afa15801561138f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b39190611cdb565b816001815181106113c6576113c6611c65565b6001600160a01b0392831660209182029290920101526014546113ec9130911684610b87565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac94790611425908590600090869030904290600401611cf8565b600060405180830381600087803b15801561143f57600080fd5b505af1158015611453573d6000803e3d6000fd5b50506015805460ff60a81b1916905550505050565b80611475576114756114fb565b611480848484611529565b80610a6857610a68600e54600c55600f54600d55565b60008060006114a3611620565b90925090506114b282826114b9565b9250505090565b60006112d883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611660565b600c5415801561150b5750600d54155b1561151257565b600c8054600e55600d8054600f5560009182905555565b60008060008060008061153b8761168e565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061156d90876116eb565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461159c908661172d565b6001600160a01b0389166000908152600260205260409020556115be8161178c565b6115c884836117d6565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161160d91815260200190565b60405180910390a3505050505050505050565b6006546000908190670de0b6b3a764000061163b82826114b9565b82101561165757505060065492670de0b6b3a764000092509050565b90939092509050565b600081836116815760405162461bcd60e51b815260040161061f9190611a1e565b5060006112188486611d69565b60008060008060008060008060006116ab8a600c54600d546117fa565b92509250925060006116bb611496565b905060008060006116ce8e87878761184f565b919e509c509a509598509396509194505050505091939550919395565b60006112d883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111e7565b60008061173a8385611cac565b9050838110156112d85760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161061f565b6000611796611496565b905060006117a4838361189f565b306000908152600260205260409020549091506117c1908261172d565b30600090815260026020526040902055505050565b6006546117e390836116eb565b6006556007546117f3908261172d565b6007555050565b6000808080611814606461180e898961189f565b906114b9565b90506000611827606461180e8a8961189f565b9050600061183f826118398b866116eb565b906116eb565b9992985090965090945050505050565b600080808061185e888661189f565b9050600061186c888761189f565b9050600061187a888861189f565b9050600061188c8261183986866116eb565b939b939a50919850919650505050505050565b6000826118ae575060006106a5565b60006118ba8385611d8b565b9050826118c78583611d69565b146112d85760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161061f565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107ef57600080fd5b803561195481611934565b919050565b6000602080838503121561196c57600080fd5b823567ffffffffffffffff8082111561198457600080fd5b818501915085601f83011261199857600080fd5b8135818111156119aa576119aa61191e565b8060051b604051601f19603f830116810181811085821117156119cf576119cf61191e565b6040529182528482019250838101850191888311156119ed57600080fd5b938501935b82851015611a1257611a0385611949565b845293850193928501926119f2565b98975050505050505050565b600060208083528351808285015260005b81811015611a4b57858101830151858201604001528201611a2f565b81811115611a5d576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215611a8657600080fd5b8235611a9181611934565b946020939093013593505050565b600080600060608486031215611ab457600080fd5b8335611abf81611934565b92506020840135611acf81611934565b929592945050506040919091013590565b600060208284031215611af257600080fd5b81356112d881611934565b8035801515811461195457600080fd5b600060208284031215611b1f57600080fd5b6112d882611afd565b600060208284031215611b3a57600080fd5b5035919050565b60008060008060808587031215611b5757600080fd5b5050823594602084013594506040840135936060013592509050565b600080600060408486031215611b8857600080fd5b833567ffffffffffffffff80821115611ba057600080fd5b818601915086601f830112611bb457600080fd5b813581811115611bc357600080fd5b8760208260051b8501011115611bd857600080fd5b602092830195509350611bee9186019050611afd565b90509250925092565b60008060408385031215611c0a57600080fd5b8235611c1581611934565b91506020830135611c2581611934565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611ca557611ca5611c7b565b5060010190565b60008219821115611cbf57611cbf611c7b565b500190565b600082821015611cd657611cd6611c7b565b500390565b600060208284031215611ced57600080fd5b81516112d881611934565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611d485784516001600160a01b031683529383019391830191600101611d23565b50506001600160a01b03969096166060850152505050608001529392505050565b600082611d8657634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611da557611da5611c7b565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220b9b18cca1f0871126e359ca131dd0ea1905de73aabc000a11112f094bc38f19864736f6c63430008090033
[ 13 ]
0xf3e14960e5b282262880bba529bf9dd98aa38761
pragma solidity ^0.5.17; /* * @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. * Refer from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/GSN/Context.sol */ 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; } } /** * @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 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 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}. * Refer from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol */ contract Token is Context, IERC20 { using SafeMath for uint256; string private _name; string private _symbol; uint8 private _decimals; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; constructor(address boss,string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; _totalSupply = 100000000e18; _balances[boss] = _totalSupply; emit Transfer(address(0), boss, _totalSupply); } /** * @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. * * 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 returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view 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 returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public 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 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 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 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 { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { 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 { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025f57806370a08231146102c557806395d89b411461031d578063a457c2d7146103a0578063a9059cbb14610406578063dd62ed3e1461046c576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019757806323b872dd146101b5578063313ce5671461023b575b600080fd5b6100b66104e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b61019f6105a4565b6040518082815260200191505060405180910390f35b610221600480360360608110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ae565b604051808215151515815260200191505060405180910390f35b610243610687565b604051808260ff1660ff16815260200191505060405180910390f35b6102ab6004803603604081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069e565b604051808215151515815260200191505060405180910390f35b610307600480360360208110156102db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610751565b6040518082815260200191505060405180910390f35b61032561079a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036557808201518184015260208101905061034a565b50505050905090810190601f1680156103925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ec600480360360408110156103b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083c565b604051808215151515815260200191505060405180910390f35b6104526004803603604081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610909565b604051808215151515815260200191505060405180910390f35b6104ce6004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610927565b6040518082815260200191505060405180910390f35b606060008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b600061059a6105936109ae565b84846109b6565b6001905092915050565b6000600554905090565b60006105bb848484610bad565b61067c846105c76109ae565b6106778560405180606001604052806028815260200161101b60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061062d6109ae565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e679092919063ffffffff16565b6109b6565b600190509392505050565b6000600260009054906101000a900460ff16905090565b60006107476106ab6109ae565b8461074285600460006106bc6109ae565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2790919063ffffffff16565b6109b6565b6001905092915050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108325780601f1061080757610100808354040283529160200191610832565b820191906000526020600020905b81548152906001019060200180831161081557829003601f168201915b5050505050905090565b60006108ff6108496109ae565b846108fa8560405180606001604052806025815260200161108c60259139600460006108736109ae565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e679092919063ffffffff16565b6109b6565b6001905092915050565b600061091d6109166109ae565b8484610bad565b6001905092915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110686024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ac2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fd36022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c33576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110436025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610cb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fb06023913960400191505060405180910390fd5b610d2581604051806060016040528060268152602001610ff560269139600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e679092919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dba81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f2790919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ed9578082015181840152602081019050610ebe565b50505050905090810190601f168015610f065780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610fa5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a7231582099f959e5b66c005b2f95d299c40547e4e8044cb26fdd02aa0090045b31fed49064736f6c63430005110032
[ 38 ]
0xf3e15b3235b71685180e521fdc6c2da3c2d9dc82
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; interface WnsRegistryV1Interface { function getWnsAddress(string memory _label) external view returns(address); } // 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 WnsOwnable { address private _owner; bytes32 private _passwordHash; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor(bytes32 hash_) { _passwordHash = hash_; _transferOwnership(msg.sender); } modifier onlyOwner() { require(owner() == msg.sender, "Ownable: caller is not the owner"); _; } function owner() public view virtual returns (address) { return _owner; } function transferOwnership(address newOwner, string memory password, bytes32 newPasswordHash) public { require(newOwner != address(0), "Ownable: new owner is the zero address"); require(keccak256(abi.encodePacked(password)) == _passwordHash, "Invalid credentials"); _transferOwnership(newOwner); _passwordHash = newPasswordHash; } function changePasswordHash(bytes32 newPasswordHash) public virtual onlyOwner { _passwordHash = newPasswordHash; } function getHash(string memory txt) public pure returns(bytes32){ return keccak256(abi.encodePacked(txt)); } /** * @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); } } pragma solidity 0.8.7; contract WnsAddresses is WnsOwnable { address private WnsRegistry_v1; WnsRegistryV1Interface wnsRegistry_v1; constructor(address registry_, bytes32 hash_) WnsOwnable(hash_) { WnsRegistry_v1 = registry_; wnsRegistry_v1 = WnsRegistryV1Interface(WnsRegistry_v1); } function setRegistry_v1(address _registry) public { require(msg.sender == owner(), "Not authorized."); WnsRegistry_v1 = _registry; wnsRegistry_v1 = WnsRegistryV1Interface(WnsRegistry_v1); } mapping(string => address) private _wnsAddresses; function setWnsAddresses(string[] memory _labels, address[] memory _addresses) public onlyOwner { require(_labels.length == _addresses.length, "Arrays do not match"); for(uint256 i=0; i<_addresses.length; i++) { _wnsAddresses[_labels[i]] = _addresses[i]; } } function getWnsAddress(string memory _label) public view returns(address) { if(_wnsAddresses[_label] != address(0)) { return _wnsAddresses[_label]; } else { return wnsRegistry_v1.getWnsAddress(_label); } } }
0x608060405234801561001057600080fd5b506004361061007d5760003560e01c806362bd39721161005b57806362bd3972146100d05780638da5cb5b146100fb578063982f36911461010c5780639b512a6f1461011f57600080fd5b80631ff0c30a14610082578063527444d7146100975780635b6beeb9146100aa575b600080fd5b610095610090366004610738565b610132565b005b6100956100a5366004610812565b61027c565b6100bd6100b836600461082b565b6102ea565b6040519081526020015b60405180910390f35b6100e36100de36600461082b565b61031a565b6040516001600160a01b0390911681526020016100c7565b6000546001600160a01b03166100e3565b61009561011a36600461069e565b610409565b61009561012d3660046106df565b610481565b336101456000546001600160a01b031690565b6001600160a01b0316146101a05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b80518251146101e75760405162461bcd60e51b8152602060048201526013602482015272082e4e4c2f2e640c8de40dcdee840dac2e8c6d606b1b6044820152606401610197565b60005b81518110156102775781818151811061020557610205610965565b6020026020010151600484838151811061022157610221610965565b60200260200101516040516102369190610868565b90815260405190819003602001902080546001600160a01b03929092166001600160a01b03199092169190911790558061026f8161093c565b9150506101ea565b505050565b3361028f6000546001600160a01b031690565b6001600160a01b0316146102e55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610197565b600155565b6000816040516020016102fd9190610868565b604051602081830303815290604052805190602001209050919050565b6000806001600160a01b03166004836040516103369190610868565b908152604051908190036020019020546001600160a01b031614610383576004826040516103649190610868565b908152604051908190036020019020546001600160a01b031692915050565b60035460405163315e9cb960e11b81526001600160a01b03909116906362bd3972906103b3908590600401610884565b60206040518083038186803b1580156103cb57600080fd5b505afa1580156103df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040391906106c2565b92915050565b6000546001600160a01b031633146104555760405162461bcd60e51b815260206004820152600f60248201526e2737ba1030baba3437b934bd32b21760891b6044820152606401610197565b600280546001600160a01b039092166001600160a01b0319928316811790915560038054909216179055565b6001600160a01b0383166104e65760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610197565b600154826040516020016104fa9190610868565b60405160208183030381529060405280519060200120146105535760405162461bcd60e51b8152602060048201526013602482015272496e76616c69642063726564656e7469616c7360681b6044820152606401610197565b61055c83610563565b6001555050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600082601f8301126105c457600080fd5b813560206105d96105d4836108e8565b6108b7565b80838252828201915082860187848660051b89010111156105f957600080fd5b60005b8581101561062157813561060f81610991565b845292840192908401906001016105fc565b5090979650505050505050565b600082601f83011261063f57600080fd5b813567ffffffffffffffff8111156106595761065961097b565b61066c601f8201601f19166020016108b7565b81815284602083860101111561068157600080fd5b816020850160208301376000918101602001919091529392505050565b6000602082840312156106b057600080fd5b81356106bb81610991565b9392505050565b6000602082840312156106d457600080fd5b81516106bb81610991565b6000806000606084860312156106f457600080fd5b83356106ff81610991565b9250602084013567ffffffffffffffff81111561071b57600080fd5b6107278682870161062e565b925050604084013590509250925092565b6000806040838503121561074b57600080fd5b823567ffffffffffffffff8082111561076357600080fd5b818501915085601f83011261077757600080fd5b813560206107876105d4836108e8565b8083825282820191508286018a848660051b89010111156107a757600080fd5b60005b858110156107e2578135878111156107c157600080fd5b6107cf8d87838c010161062e565b85525092840192908401906001016107aa565b509097505050860135925050808211156107fb57600080fd5b50610808858286016105b3565b9150509250929050565b60006020828403121561082457600080fd5b5035919050565b60006020828403121561083d57600080fd5b813567ffffffffffffffff81111561085457600080fd5b6108608482850161062e565b949350505050565b6000825161087a81846020870161090c565b9190910192915050565b60208152600082518060208401526108a381604085016020870161090c565b601f01601f19169190910160400192915050565b604051601f8201601f1916810167ffffffffffffffff811182821017156108e0576108e061097b565b604052919050565b600067ffffffffffffffff8211156109025761090261097b565b5060051b60200190565b60005b8381101561092757818101518382015260200161090f565b83811115610936576000848401525b50505050565b600060001982141561095e57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146109a657600080fd5b5056fea2646970667358221220ad1752f4b7dcb1cce696f955c2a657a5796af181bf8d484ce3f1216832fddf6364736f6c63430008070033
[ 38 ]
0xf3e19febc89a34845bf44d2af8461b53968ba521
// SPDX-License-Identifier: SEE LICENSE IN LICENSE pragma solidity 0.6.12; interface IERC20Token { function allowance(address _owner, address _spender) external view returns (uint256); function transferFrom(address _from, address _to, uint256 _value) external returns (bool); } contract USDCMigratorProxy { address public owner; constructor() public { owner = msg.sender; } function transferUSDCMigratorProxy(IERC20Token _token, address _sender, address _receiver, uint256 _amount) external returns (bool) { require(msg.sender == owner, "access denied"); return _token.transferFrom(_sender, _receiver, _amount); } }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636c3bfdba1461003b5780638da5cb5b146100df575b600080fd5b6100c76004803603608081101561005157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610113565b60405180821515815260200191505060405180910390f35b6100e76102ab565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f6163636573732064656e6965640000000000000000000000000000000000000081525060200191505060405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd8585856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561026657600080fd5b505af115801561027a573d6000803e3d6000fd5b505050506040513d602081101561029057600080fd5b81019080805190602001909291905050509050949350505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea26469706673582212208f2aab7ea2805fca0337417393ca2a256763a44bfb480245d9fdef50f4ec49c864736f6c634300060c0033
[ 38 ]